service

package
v1.4.8 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package service provides a service layer between interfaces (CLI/MCP) and the Linear client. It handles business logic, validation, identifier resolution, and response formatting.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnalyzeInput

type AnalyzeInput struct {
	TeamID                string
	CycleCount            int
	AssigneeID            string
	IncludeRecommendation bool
}

AnalyzeInput represents input for cycle analysis

type CreateCycleInput

type CreateCycleInput struct {
	TeamID      string
	Name        string
	Description string
	StartsAt    string
	EndsAt      string
}

CreateCycleInput represents input for creating a cycle

type CreateIssueInput

type CreateIssueInput struct {
	Title       string
	Description string
	TeamID      string
	StateID     string
	AssigneeID  string
	ProjectID   string
	ParentID    string
	CycleID     string
	Priority    *int
	Estimate    *float64
	DueDate     string
	LabelIDs    []string
	DependsOn   []string // Issue identifiers this issue depends on (stored in metadata)
	BlockedBy   []string // Issue identifiers that block this issue (stored in metadata)
}

CreateIssueInput represents input for creating an issue

type CreateProjectInput

type CreateProjectInput struct {
	Name        string
	Description string
	TeamID      string
	State       string // planned, started, paused, completed, canceled
	LeadID      string // Project lead user ID
	StartDate   string // Start date YYYY-MM-DD
	EndDate     string // Target end date YYYY-MM-DD
}

CreateProjectInput represents input for creating a project

type CycleClientOperations added in v1.3.0

type CycleClientOperations interface {
	// Smart resolver-aware methods (kept in Phase 2)
	ListCycles(filter *core.CycleFilter) (*core.CycleSearchResult, error)
	GetActiveCycle(teamKeyOrName string) (*core.Cycle, error)
	CreateCycle(input *core.CreateCycleInput) (*core.Cycle, error)

	// Resolver operations
	ResolveTeamIdentifier(keyOrName string) (string, error)
	ResolveCycleIdentifier(numberOrNameOrID, teamID string) (string, error)
	ResolveUserIdentifier(nameOrEmail string) (*linear.ResolvedUser, error)

	// Sub-client access (Phase 2 - use sub-clients directly)
	CycleClient() *cycles.Client
}

CycleClientOperations defines the minimal interface needed by CycleService

type CycleFilters

type CycleFilters struct {
	TeamID   string
	IsActive *bool
	IsFuture *bool
	IsPast   *bool
	Limit    int
	After    string
	Format   format.Format
}

CycleFilters represents filters for searching cycles

type CycleService

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

CycleService handles cycle-related operations

func NewCycleService

func NewCycleService(client CycleClientOperations, formatter *format.Formatter) *CycleService

NewCycleService creates a new CycleService

func (*CycleService) Analyze

func (s *CycleService) Analyze(input *AnalyzeInput) (string, error)

Analyze performs cycle analytics for capacity planning (legacy method)

func (*CycleService) AnalyzeWithOutput added in v1.3.0

func (s *CycleService) AnalyzeWithOutput(input *AnalyzeInput, verbosity format.Verbosity, outputType format.OutputType) (string, error)

AnalyzeWithOutput performs cycle analytics with new renderer architecture

func (*CycleService) Create

func (s *CycleService) Create(input *CreateCycleInput) (string, error)

Create creates a new cycle

func (*CycleService) Get

func (s *CycleService) Get(cycleIDOrNumber string, teamID string, outputFormat format.Format) (string, error)

Get retrieves a single cycle by ID, number, or name (legacy method)

func (*CycleService) GetWithOutput added in v1.3.0

func (s *CycleService) GetWithOutput(cycleIDOrNumber string, teamID string, verbosity format.Verbosity, outputType format.OutputType) (string, error)

GetWithOutput retrieves a single cycle with new renderer architecture

func (*CycleService) Search

func (s *CycleService) Search(filters *CycleFilters) (string, error)

Search searches for cycles with the given filters (legacy method)

func (*CycleService) SearchWithOutput added in v1.3.0

func (s *CycleService) SearchWithOutput(filters *CycleFilters, verbosity format.Verbosity, outputType format.OutputType) (string, error)

SearchWithOutput searches for cycles with new renderer architecture

type CycleServiceInterface added in v1.3.0

type CycleServiceInterface interface {
	Get(cycleIDOrNumber string, teamID string, outputFormat format.Format) (string, error)
	GetWithOutput(cycleIDOrNumber string, teamID string, verbosity format.Verbosity, outputType format.OutputType) (string, error)
	Search(filters *CycleFilters) (string, error)
	SearchWithOutput(filters *CycleFilters, verbosity format.Verbosity, outputType format.OutputType) (string, error)
	Create(input *CreateCycleInput) (string, error)
	Analyze(input *AnalyzeInput) (string, error)
	AnalyzeWithOutput(input *AnalyzeInput, verbosity format.Verbosity, outputType format.OutputType) (string, error)
}

CycleServiceInterface defines the contract for cycle operations

type ExportResult added in v1.3.0

type ExportResult struct {
	Tasks             []taskwriter.ClaudeTask
	TotalTasks        int
	DependencyCount   int
	CircularDepsFound []string
}

ExportResult contains the result of an export operation

type IssueClientOperations added in v1.3.0

type IssueClientOperations interface {
	// Smart resolver-aware methods (kept in Phase 2)
	CreateIssue(title, description, teamKeyOrName string) (*core.Issue, error)
	GetIssue(identifierOrID string) (*core.Issue, error)
	UpdateIssue(identifierOrID string, input core.UpdateIssueInput) (*core.Issue, error)
	UpdateIssueState(identifierOrID, stateID string) error
	AssignIssue(identifierOrID, assigneeNameOrEmail string) error
	ListAssignedIssues(limit int) ([]core.Issue, error)
	SearchIssues(filters *core.IssueSearchFilters) (*core.IssueSearchResult, error)

	// Resolver operations
	ResolveTeamIdentifier(keyOrName string) (string, error)
	ResolveUserIdentifier(nameOrEmail string) (*linear.ResolvedUser, error)
	ResolveCycleIdentifier(numberOrNameOrID, teamID string) (string, error)
	ResolveLabelIdentifier(labelName, teamID string) (string, error)
	ResolveProjectIdentifier(nameOrID string) (string, error)

	// Metadata operations (kept in Phase 2)
	UpdateIssueMetadataKey(issueID, key string, value interface{}) error

	// Sub-client access (Phase 2 - use sub-clients directly)
	CommentClient() *comments.Client
	WorkflowClient() *workflows.Client
	IssueClient() *issues.Client
	TeamClient() *teams.Client
}

IssueClientOperations defines the minimal interface needed by IssueService. This follows the "consumer defines interface" pattern for dependency injection, enabling mock implementations for unit testing.

type IssueService

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

IssueService handles issue-related operations

func NewIssueService

func NewIssueService(client IssueClientOperations, formatter *format.Formatter) *IssueService

NewIssueService creates a new IssueService

func (*IssueService) AddComment

func (s *IssueService) AddComment(identifier, body string) (string, error)

AddComment adds a comment to an issue

func (*IssueService) AddReaction

func (s *IssueService) AddReaction(targetID, emoji string) error

AddReaction adds a reaction to an issue or comment

func (*IssueService) Create

func (s *IssueService) Create(input *CreateIssueInput) (string, error)

Create creates a new issue

func (*IssueService) Get

func (s *IssueService) Get(identifier string, outputFormat format.Format) (string, error)

Get retrieves a single issue by identifier (e.g., "CEN-123")

func (*IssueService) GetComments

func (s *IssueService) GetComments(identifier string) (string, error)

GetComments returns comments for an issue

func (*IssueService) GetIssueID

func (s *IssueService) GetIssueID(identifier string) (string, error)

GetIssueID resolves an issue identifier to its UUID

func (*IssueService) GetWithOutput added in v1.3.0

func (s *IssueService) GetWithOutput(identifier string, verbosity format.Verbosity, outputType format.OutputType) (string, error)

GetWithOutput retrieves a single issue with new renderer architecture

func (*IssueService) ListAssigned

func (s *IssueService) ListAssigned(limit int, outputFormat format.Format) (string, error)

ListAssigned lists issues assigned to the current user

func (*IssueService) ListAssignedWithPagination

func (s *IssueService) ListAssignedWithPagination(pagination *core.PaginationInput) (string, error)

ListAssignedWithPagination lists assigned issues with offset-based pagination

func (*IssueService) ReplyToComment

func (s *IssueService) ReplyToComment(issueIdentifier, parentCommentID, body string) (*core.Comment, error)

ReplyToComment replies to an existing comment

func (*IssueService) Search

func (s *IssueService) Search(filters *SearchFilters) (string, error)

Search searches for issues with the given filters

func (*IssueService) SearchWithOutput added in v1.3.0

func (s *IssueService) SearchWithOutput(filters *SearchFilters, verbosity format.Verbosity, outputType format.OutputType) (string, error)

SearchWithOutput searches for issues with new renderer architecture

func (*IssueService) Update

func (s *IssueService) Update(identifier string, input *UpdateIssueInput) (string, error)

Update updates an existing issue

type IssueServiceInterface added in v1.3.0

type IssueServiceInterface interface {
	Get(identifier string, outputFormat format.Format) (string, error)
	GetWithOutput(identifier string, verbosity format.Verbosity, outputType format.OutputType) (string, error)
	Search(filters *SearchFilters) (string, error)
	SearchWithOutput(filters *SearchFilters, verbosity format.Verbosity, outputType format.OutputType) (string, error)
	ListAssigned(limit int, outputFormat format.Format) (string, error)
	ListAssignedWithPagination(pagination *core.PaginationInput) (string, error)
	Create(input *CreateIssueInput) (string, error)
	Update(identifier string, input *UpdateIssueInput) (string, error)
	GetComments(identifier string) (string, error)
	AddComment(identifier, body string) (string, error)
	ReplyToComment(issueIdentifier, parentCommentID, body string) (*core.Comment, error)
	AddReaction(targetID, emoji string) error
	GetIssueID(identifier string) (string, error)
}

IssueServiceInterface defines the contract for issue operations

type ProjectClientOperations added in v1.3.0

type ProjectClientOperations interface {
	// Smart resolver-aware methods (kept in Phase 2)
	CreateProject(name, description, teamKeyOrName string) (*core.Project, error)

	// Resolver operations
	ResolveTeamIdentifier(keyOrName string) (string, error)
	ResolveUserIdentifier(nameOrEmail string) (*linear.ResolvedUser, error)

	// Sub-client access (Phase 2 - use sub-clients directly)
	ProjectClient() *projects.Client
	TeamClient() *teams.Client
}

ProjectClientOperations defines the minimal interface needed by ProjectService

type ProjectService

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

ProjectService handles project-related operations

func NewProjectService

func NewProjectService(client ProjectClientOperations, formatter *format.Formatter) *ProjectService

NewProjectService creates a new ProjectService

func (*ProjectService) Create

func (s *ProjectService) Create(input *CreateProjectInput) (string, error)

Create creates a new project

func (*ProjectService) Get

func (s *ProjectService) Get(projectID string) (string, error)

Get retrieves a single project by ID (legacy method)

func (*ProjectService) GetWithOutput added in v1.3.0

func (s *ProjectService) GetWithOutput(projectID string, verbosity format.Verbosity, outputType format.OutputType) (string, error)

GetWithOutput retrieves a single project with new renderer architecture

func (*ProjectService) ListAll

func (s *ProjectService) ListAll(limit int) (string, error)

ListAll lists all projects in the workspace (legacy method)

func (*ProjectService) ListAllWithOutput added in v1.3.0

func (s *ProjectService) ListAllWithOutput(limit int, verbosity format.Verbosity, outputType format.OutputType) (string, error)

ListAllWithOutput lists all projects with new renderer architecture

func (*ProjectService) ListByTeam added in v1.3.0

func (s *ProjectService) ListByTeam(teamID string, limit int) (string, error)

ListByTeam lists all projects for a specific team (legacy method)

func (*ProjectService) ListByTeamWithOutput added in v1.3.0

func (s *ProjectService) ListByTeamWithOutput(teamID string, limit int, verbosity format.Verbosity, outputType format.OutputType) (string, error)

ListByTeamWithOutput lists all projects for a team with new renderer architecture

func (*ProjectService) ListUserProjects

func (s *ProjectService) ListUserProjects(limit int) (string, error)

ListUserProjects lists projects that have issues assigned to the user (legacy method)

func (*ProjectService) ListUserProjectsWithOutput added in v1.3.0

func (s *ProjectService) ListUserProjectsWithOutput(limit int, verbosity format.Verbosity, outputType format.OutputType) (string, error)

ListUserProjectsWithOutput lists user projects with new renderer architecture

func (*ProjectService) Update

func (s *ProjectService) Update(projectID string, input *UpdateProjectInput) (string, error)

Update updates an existing project

type ProjectServiceInterface added in v1.3.0

type ProjectServiceInterface interface {
	Get(projectID string) (string, error)
	GetWithOutput(projectID string, verbosity format.Verbosity, outputType format.OutputType) (string, error)
	ListAll(limit int) (string, error)
	ListAllWithOutput(limit int, verbosity format.Verbosity, outputType format.OutputType) (string, error)
	ListByTeam(teamID string, limit int) (string, error)
	ListByTeamWithOutput(teamID string, limit int, verbosity format.Verbosity, outputType format.OutputType) (string, error)
	ListUserProjects(limit int) (string, error)
	ListUserProjectsWithOutput(limit int, verbosity format.Verbosity, outputType format.OutputType) (string, error)
	Create(input *CreateProjectInput) (string, error)
	Update(projectID string, input *UpdateProjectInput) (string, error)
}

ProjectServiceInterface defines the contract for project operations

type SearchClientOperations added in v1.3.0

type SearchClientOperations interface {
	// Smart resolver-aware methods (kept in Phase 2)
	SearchIssues(filters *core.IssueSearchFilters) (*core.IssueSearchResult, error)
	ListCycles(filter *core.CycleFilter) (*core.CycleSearchResult, error)

	// Resolver operations
	ResolveTeamIdentifier(keyOrName string) (string, error)
	ResolveUserIdentifier(nameOrEmail string) (*linear.ResolvedUser, error)
	ResolveCycleIdentifier(numberOrNameOrID, teamID string) (string, error)
	ResolveLabelIdentifier(labelName, teamID string) (string, error)

	// Sub-client access (Phase 2 - use sub-clients directly)
	IssueClient() *issues.Client
	ProjectClient() *projects.Client
	TeamClient() *teams.Client
	WorkflowClient() *workflows.Client
}

SearchClientOperations defines the minimal interface needed by SearchService

type SearchFilters

type SearchFilters struct {
	TeamID     string
	AssigneeID string
	CycleID    string
	StateIDs   []string
	LabelIDs   []string
	Priority   *int
	SearchTerm string
	Limit      int
	After      string
	Format     format.Format
}

SearchFilters represents filters for searching issues

type SearchOptions added in v1.2.0

type SearchOptions struct {
	EntityType string
	TextQuery  string

	// Standard filters
	TeamID     string
	StateIDs   []string
	Priority   *int
	AssigneeID string
	CycleID    string
	LabelIDs   []string

	// Dependency filters (NEW)
	BlockedBy   string // Issue ID that blocks results
	Blocks      string // Issue ID that results block
	HasBlockers bool   // Filter to issues with blockers
	HasDeps     bool   // Filter to issues with dependencies
	HasCircular bool   // Filter to issues in circular deps
	MaxDepth    int    // Max dependency depth

	// Pagination
	Limit  int
	After  string
	Format format.Format
}

SearchOptions represents unified search parameters

type SearchService added in v1.2.0

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

SearchService handles unified search operations across entities

func NewSearchService added in v1.2.0

func NewSearchService(client SearchClientOperations, formatter *format.Formatter) *SearchService

NewSearchService creates a new SearchService

func (*SearchService) Search added in v1.2.0

func (s *SearchService) Search(opts *SearchOptions) (string, error)

Search performs unified search across entities

type SearchServiceInterface added in v1.3.0

type SearchServiceInterface interface {
	Search(opts *SearchOptions) (string, error)
}

SearchServiceInterface defines the contract for unified search

type Services

type Services struct {
	Issues     *IssueService
	Projects   *ProjectService
	Cycles     *CycleService
	Teams      *TeamService
	Users      *UserService
	Search     *SearchService
	TaskExport *TaskExportService
	// contains filtered or unexported fields
}

Services holds all service instances

func New

func New(client *linear.Client) *Services

New creates all services with a shared Linear client and formatter

func (*Services) Client

func (s *Services) Client() *linear.Client

Client returns the underlying Linear client for advanced operations

type TaskExportService added in v1.3.0

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

TaskExportService handles exporting Linear issues to Claude Code task format

func NewTaskExportService added in v1.3.0

func NewTaskExportService(issueClient IssueClientOperations) *TaskExportService

NewTaskExportService creates a new TaskExportService

func (*TaskExportService) Export added in v1.3.0

func (s *TaskExportService) Export(identifier string, outputFolder string, dryRun bool) (*ExportResult, error)

Export exports a Linear issue and its complete dependency tree to Claude Code task format Returns an error if circular dependencies are detected

type TaskExportServiceInterface added in v1.3.0

type TaskExportServiceInterface interface {
	Export(identifier string, outputFolder string, dryRun bool) (*ExportResult, error)
}

TaskExportServiceInterface defines the contract for task export operations

type TeamService

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

TeamService handles team-related operations

func NewTeamService

func NewTeamService(client *linear.Client, formatter *format.Formatter) *TeamService

NewTeamService creates a new TeamService

func (*TeamService) Get

func (s *TeamService) Get(identifier string) (string, error)

Get retrieves a single team by ID or key (legacy method)

func (*TeamService) GetLabels

func (s *TeamService) GetLabels(identifier string) (string, error)

GetLabels returns labels for a team (legacy method)

func (*TeamService) GetLabelsWithOutput added in v1.3.0

func (s *TeamService) GetLabelsWithOutput(identifier string, verbosity format.Verbosity, outputType format.OutputType) (string, error)

GetLabelsWithOutput returns labels for a team with new renderer architecture

func (*TeamService) GetWithOutput added in v1.3.0

func (s *TeamService) GetWithOutput(identifier string, verbosity format.Verbosity, outputType format.OutputType) (string, error)

GetWithOutput retrieves a single team with new renderer architecture

func (*TeamService) GetWorkflowStates

func (s *TeamService) GetWorkflowStates(identifier string) (string, error)

GetWorkflowStates returns workflow states for a team (legacy method)

func (*TeamService) GetWorkflowStatesWithOutput added in v1.3.0

func (s *TeamService) GetWorkflowStatesWithOutput(identifier string, verbosity format.Verbosity, outputType format.OutputType) (string, error)

GetWorkflowStatesWithOutput returns workflow states with new renderer architecture

func (*TeamService) ListAll

func (s *TeamService) ListAll() (string, error)

ListAll lists all teams in the workspace (legacy method)

func (*TeamService) ListAllWithOutput added in v1.3.0

func (s *TeamService) ListAllWithOutput(verbosity format.Verbosity, outputType format.OutputType) (string, error)

ListAllWithOutput lists all teams with new renderer architecture

type TeamServiceInterface added in v1.3.0

type TeamServiceInterface interface {
	Get(identifier string) (string, error)
	GetWithOutput(identifier string, verbosity format.Verbosity, outputType format.OutputType) (string, error)
	ListAll() (string, error)
	ListAllWithOutput(verbosity format.Verbosity, outputType format.OutputType) (string, error)
	GetLabels(identifier string) (string, error)
	GetLabelsWithOutput(identifier string, verbosity format.Verbosity, outputType format.OutputType) (string, error)
	GetWorkflowStates(identifier string) (string, error)
	GetWorkflowStatesWithOutput(identifier string, verbosity format.Verbosity, outputType format.OutputType) (string, error)
}

TeamServiceInterface defines the contract for team operations

type UpdateIssueInput

type UpdateIssueInput struct {
	Title       *string
	Description *string
	StateID     *string
	AssigneeID  *string
	ProjectID   *string
	ParentID    *string
	TeamID      *string
	CycleID     *string
	Priority    *int
	Estimate    *float64
	DueDate     *string
	LabelIDs    []string
	DependsOn   []string // Issue identifiers this issue depends on (stored in metadata)
	BlockedBy   []string // Issue identifiers that block this issue (stored in metadata)
}

UpdateIssueInput represents input for updating an issue

type UpdateProjectInput

type UpdateProjectInput struct {
	Name        *string
	Description *string
	State       *string // planned, started, paused, completed, canceled
	LeadID      *string // Project lead user ID
	StartDate   *string // Start date YYYY-MM-DD
	EndDate     *string // Target end date YYYY-MM-DD
}

UpdateProjectInput represents input for updating a project

type UserClientOperations added in v1.3.0

type UserClientOperations interface {
	// Smart resolver-aware methods (kept in Phase 2)
	GetUser(idOrEmail string) (*core.User, error)

	// Resolver operations
	ResolveUserIdentifier(nameOrEmail string) (*linear.ResolvedUser, error)
	ResolveTeamIdentifier(keyOrName string) (string, error)

	// Sub-client access (Phase 2 - use sub-clients directly)
	TeamClient() *teams.Client
}

UserClientOperations defines the minimal interface needed by UserService

type UserFilters

type UserFilters struct {
	TeamID     string
	ActiveOnly *bool
	Limit      int
	After      string
}

UserFilters represents filters for searching users

type UserService

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

UserService handles user-related operations

func NewUserService

func NewUserService(client UserClientOperations, formatter *format.Formatter) *UserService

NewUserService creates a new UserService

func (*UserService) Get

func (s *UserService) Get(identifier string) (string, error)

Get retrieves a single user by identifier (email, name, or ID) (legacy method)

func (*UserService) GetViewer

func (s *UserService) GetViewer() (string, error)

GetViewer returns the current authenticated user (legacy method)

func (*UserService) GetViewerWithOutput added in v1.3.0

func (s *UserService) GetViewerWithOutput(verbosity format.Verbosity, outputType format.OutputType) (string, error)

GetViewerWithOutput returns the current user with new renderer architecture

func (*UserService) GetWithOutput added in v1.3.0

func (s *UserService) GetWithOutput(identifier string, verbosity format.Verbosity, outputType format.OutputType) (string, error)

GetWithOutput retrieves a single user with new renderer architecture

func (*UserService) ResolveByName

func (s *UserService) ResolveByName(name string) (string, error)

ResolveByName resolves a user by name and returns their ID Supports: - "me" - returns current authenticated user - Email addresses: "john@company.com" - Display names: "John Doe" - Partial names: "John" (errors if ambiguous with suggestions)

Returns error with multiple user names if ambiguous

func (*UserService) Search

func (s *UserService) Search(filters *UserFilters) (string, error)

Search searches for users with the given filters (legacy method)

func (*UserService) SearchWithOutput added in v1.3.0

func (s *UserService) SearchWithOutput(filters *UserFilters, verbosity format.Verbosity, outputType format.OutputType) (string, error)

SearchWithOutput searches for users with new renderer architecture

type UserServiceInterface added in v1.3.0

type UserServiceInterface interface {
	GetViewer() (string, error)
	GetViewerWithOutput(verbosity format.Verbosity, outputType format.OutputType) (string, error)
	Get(identifier string) (string, error)
	GetWithOutput(identifier string, verbosity format.Verbosity, outputType format.OutputType) (string, error)
	Search(filters *UserFilters) (string, error)
	SearchWithOutput(filters *UserFilters, verbosity format.Verbosity, outputType format.OutputType) (string, error)
	ResolveByName(name string) (string, error)
}

UserServiceInterface defines the contract for user operations

Jump to

Keyboard shortcuts

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