work

package
v0.1.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package work provides work unit management and tab operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectIssueIDsForAutomatedWorkflow

func CollectIssueIDsForAutomatedWorkflow(ctx context.Context, beadID string, beadsReader beads.Reader) ([]string, error)

CollectIssueIDsForAutomatedWorkflow collects all issue IDs to include in the workflow. It includes: - The issue itself - All children recursively (parent-child dependents) - All blocked issues recursively (blocks dependents) - For issues without children/blocked, all transitive dependencies

func EnsureUniqueBranchName

func EnsureUniqueBranchName(ctx context.Context, gitOps git.Operations, repoPath, baseName string) (string, error)

EnsureUniqueBranchName checks if a branch already exists and appends a suffix if needed. Returns a unique branch name that doesn't conflict with existing branches. The gitOps parameter allows dependency injection for testing.

func GenerateBranchNameFromIssue

func GenerateBranchNameFromIssue(issue *beads.Bead) string

GenerateBranchNameFromIssue creates a git-friendly branch name from an issue's title. It converts the title to lowercase, replaces spaces with hyphens, removes special characters, and prefixes with "feat/".

func GenerateBranchNameFromIssues

func GenerateBranchNameFromIssues(issues []*beads.Bead) string

GenerateBranchNameFromIssues creates a git-friendly branch name from multiple issues' titles. For a single issue, it uses that issue's title. For multiple issues, it combines titles (truncated) or uses a generic name if too long.

func ParseBeadIDs

func ParseBeadIDs(beadIDStr string) []string

ParseBeadIDs parses a comma-delimited string of bead IDs into a slice. It trims whitespace from each ID and filters out empty strings.

func PlanTabName

func PlanTabName(beadID string) string

PlanTabName returns the zellij tab name for a bead's planning session.

Types

type AddBeadsToWorkResult

type AddBeadsToWorkResult struct {
	BeadsAdded int
}

AddBeadsToWorkResult contains the result of adding beads to a work.

type CreateBeadOptions

type CreateBeadOptions struct {
	// BeadsDir is the directory containing the beads database.
	BeadsDir string
	// SkipIfExists skips creation if a bead with the same PR URL already exists.
	SkipIfExists bool
	// OverrideTitle allows overriding the PR title.
	OverrideTitle string
	// OverrideType allows overriding the inferred type.
	OverrideType string
	// OverridePriority allows overriding the inferred priority.
	OverridePriority string
}

CreateBeadOptions contains options for creating a bead from a PR.

type CreateBeadResult

type CreateBeadResult struct {
	BeadID     string
	Created    bool
	SkipReason string
}

CreateBeadResult contains the result of creating a bead from a PR.

type CreateWorkAsyncOptions

type CreateWorkAsyncOptions struct {
	BranchName        string
	BaseBranch        string
	RootIssueID       string
	Auto              bool
	UseExistingBranch bool
	BeadIDs           []string // Beads to add to the work (added immediately, not by control plane)
}

CreateWorkAsyncOptions contains options for creating a work unit asynchronously.

type CreateWorkAsyncResult

type CreateWorkAsyncResult struct {
	WorkID      string
	WorkerName  string
	BranchName  string
	BaseBranch  string
	RootIssueID string
}

CreateWorkAsyncResult contains the result of creating a work unit asynchronously.

type CreateWorkFromBeadOptions

type CreateWorkFromBeadOptions struct {
	BeadID            string // Root bead ID to create work from
	BranchName        string
	BaseBranch        string
	Auto              bool
	UseExistingBranch bool
}

CreateWorkFromBeadOptions contains options for creating a work from a bead. This is the high-level API that handles bead expansion, work creation, and control plane initialization.

type CreateWorkFromBeadResult

type CreateWorkFromBeadResult struct {
	WorkID     string
	WorkerName string
	BranchName string
	BaseBranch string
	BeadIDs    []string // All expanded bead IDs
}

CreateWorkFromBeadResult contains the result of creating a work from a bead.

type DefaultOrchestratorManager

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

DefaultOrchestratorManager is the default implementation of OrchestratorManager. It holds the database reference needed for orchestrator heartbeat checking.

func (*DefaultOrchestratorManager) EnsureWorkOrchestrator

func (m *DefaultOrchestratorManager) EnsureWorkOrchestrator(ctx context.Context, workID string, projectName string, workDir string, friendlyName string, w io.Writer) (bool, error)

EnsureWorkOrchestrator checks if a work orchestrator tab exists and spawns one if not. This is used for resilience - if the orchestrator crashes or is killed, it can be restarted. Returns true if the orchestrator was spawned, false if it was already running. Progress messages are written to the provided writer. Pass io.Discard to suppress output.

func (*DefaultOrchestratorManager) OpenClaudeSession

func (m *DefaultOrchestratorManager) OpenClaudeSession(ctx context.Context, workID string, projectName string, workDir string, friendlyName string, hooksEnv []string, cfg *project.Config, w io.Writer) error

OpenClaudeSession creates a zellij tab with an interactive Claude Code session in the work's worktree. The tab is named "claude-<work-id>" or "claude-<work-id> (friendlyName)" for easy identification. The hooksEnv parameter contains environment variables to export (format: "KEY=value"). The config parameter controls Claude settings like --dangerously-skip-permissions. Progress messages are written to the provided writer. Pass io.Discard to suppress output.

IMPORTANT: The zellij session must already exist before calling this function. Callers should use control.EnsureControlPlane to ensure the session exists with the control plane running.

func (*DefaultOrchestratorManager) OpenConsole

func (m *DefaultOrchestratorManager) OpenConsole(ctx context.Context, workID string, projectName string, workDir string, friendlyName string, hooksEnv []string, w io.Writer) error

OpenConsole creates a zellij tab with a shell in the work's worktree. The tab is named "console-<work-id>" or "console-<work-id> (friendlyName)" for easy identification. The hooksEnv parameter contains environment variables to export (format: "KEY=value"). Progress messages are written to the provided writer. Pass io.Discard to suppress output.

IMPORTANT: The zellij session must already exist before calling this function. Callers should use control.EnsureControlPlane to ensure the session exists with the control plane running.

func (*DefaultOrchestratorManager) SpawnPlanSession

func (m *DefaultOrchestratorManager) SpawnPlanSession(ctx context.Context, beadID string, projectName string, mainRepoPath string, w io.Writer) error

SpawnPlanSession creates a zellij tab and runs the plan command for a bead. The tab is named "plan-<bead-id>" for easy identification. The function returns immediately after spawning - the plan session runs in the tab. Progress messages are written to the provided writer. Pass io.Discard to suppress output.

IMPORTANT: The zellij session must already exist before calling this function. Callers should use control.EnsureControlPlane to ensure the session exists with the control plane running.

func (*DefaultOrchestratorManager) SpawnWorkOrchestrator

func (m *DefaultOrchestratorManager) SpawnWorkOrchestrator(ctx context.Context, workID string, projectName string, workDir string, friendlyName string, w io.Writer) error

SpawnWorkOrchestrator creates a zellij tab and runs the orchestrate command for a work unit. The tab is named "work-<work-id>" or "work-<work-id> (friendlyName)" for easy identification. The function returns immediately after spawning - the orchestrator runs in the tab. Progress messages are written to the provided writer. Pass io.Discard to suppress output.

IMPORTANT: The zellij session must already exist before calling this function. Callers should use control.EnsureControlPlane to ensure the session exists with the control plane running.

func (*DefaultOrchestratorManager) TerminateWorkTabs

func (m *DefaultOrchestratorManager) TerminateWorkTabs(ctx context.Context, workID string, projectName string, w io.Writer) error

TerminateWorkTabs terminates all zellij tabs associated with a work unit. This includes the work orchestrator tab (work-<workID>), task tabs (task-<workID>.*), console tabs (console-<workID>*), and claude tabs (claude-<workID>*). Each tab's running process is terminated with Ctrl+C before the tab is closed. Progress messages are written to the provided writer. Pass io.Discard to suppress output.

type ImportPRAsyncOptions

type ImportPRAsyncOptions struct {
	PRURL       string
	BranchName  string
	RootIssueID string
}

ImportPRAsyncOptions contains options for importing a PR asynchronously.

type ImportPRAsyncResult

type ImportPRAsyncResult struct {
	WorkID      string
	WorkerName  string
	BranchName  string
	RootIssueID string
}

ImportPRAsyncResult contains the result of scheduling a PR import.

type OrchestratorManager

type OrchestratorManager interface {
	// EnsureWorkOrchestrator checks if a work orchestrator tab exists and spawns one if not.
	// Returns true if the orchestrator was spawned, false if it was already running.
	EnsureWorkOrchestrator(ctx context.Context, workID, projName, workDir, friendlyName string, w io.Writer) (bool, error)

	// SpawnWorkOrchestrator creates a zellij tab and runs the orchestrate command for a work unit.
	SpawnWorkOrchestrator(ctx context.Context, workID, projName, workDir, friendlyName string, w io.Writer) error

	// TerminateWorkTabs terminates all zellij tabs associated with a work unit.
	TerminateWorkTabs(ctx context.Context, workID, projName string, w io.Writer) error

	// SpawnPlanSession creates a zellij tab and runs the plan command for a bead.
	SpawnPlanSession(ctx context.Context, beadID, projName, mainRepoPath string, w io.Writer) error

	// OpenConsole creates a zellij tab with a shell in the work's worktree.
	OpenConsole(ctx context.Context, workID, projName, workDir, friendlyName string, hooksEnv []string, w io.Writer) error

	// OpenClaudeSession creates a zellij tab with an interactive Claude Code session.
	OpenClaudeSession(ctx context.Context, workID, projName, workDir, friendlyName string, hooksEnv []string, cfg *project.Config, w io.Writer) error
}

OrchestratorManager provides operations for managing work orchestrators and related tabs. This interface enables dependency injection and testing of orchestrator management.

func NewOrchestratorManager

func NewOrchestratorManager(database *db.DB) OrchestratorManager

NewOrchestratorManager creates a new DefaultOrchestratorManager with the given database.

func NewOrchestratorManagerWithDeps

func NewOrchestratorManagerWithDeps(database *db.DB, zc zellij.SessionManager) OrchestratorManager

NewOrchestratorManagerWithDeps creates a new DefaultOrchestratorManager with explicit dependencies. This is the preferred constructor for testing.

type OrchestratorManagerMock

type OrchestratorManagerMock struct {
	// EnsureWorkOrchestratorFunc mocks the EnsureWorkOrchestrator method.
	EnsureWorkOrchestratorFunc func(ctx context.Context, workID string, projName string, workDir string, friendlyName string, w io.Writer) (bool, error)

	// OpenClaudeSessionFunc mocks the OpenClaudeSession method.
	OpenClaudeSessionFunc func(ctx context.Context, workID string, projName string, workDir string, friendlyName string, hooksEnv []string, cfg *project.Config, w io.Writer) error

	// OpenConsoleFunc mocks the OpenConsole method.
	OpenConsoleFunc func(ctx context.Context, workID string, projName string, workDir string, friendlyName string, hooksEnv []string, w io.Writer) error

	// SpawnPlanSessionFunc mocks the SpawnPlanSession method.
	SpawnPlanSessionFunc func(ctx context.Context, beadID string, projName string, mainRepoPath string, w io.Writer) error

	// SpawnWorkOrchestratorFunc mocks the SpawnWorkOrchestrator method.
	SpawnWorkOrchestratorFunc func(ctx context.Context, workID string, projName string, workDir string, friendlyName string, w io.Writer) error

	// TerminateWorkTabsFunc mocks the TerminateWorkTabs method.
	TerminateWorkTabsFunc func(ctx context.Context, workID string, projName string, w io.Writer) error
	// contains filtered or unexported fields
}

OrchestratorManagerMock is a mock implementation of OrchestratorManager.

func TestSomethingThatUsesOrchestratorManager(t *testing.T) {

	// make and configure a mocked OrchestratorManager
	mockedOrchestratorManager := &OrchestratorManagerMock{
		EnsureWorkOrchestratorFunc: func(ctx context.Context, workID string, projName string, workDir string, friendlyName string, w io.Writer) (bool, error) {
			panic("mock out the EnsureWorkOrchestrator method")
		},
		OpenClaudeSessionFunc: func(ctx context.Context, workID string, projName string, workDir string, friendlyName string, hooksEnv []string, cfg *project.Config, w io.Writer) error {
			panic("mock out the OpenClaudeSession method")
		},
		OpenConsoleFunc: func(ctx context.Context, workID string, projName string, workDir string, friendlyName string, hooksEnv []string, w io.Writer) error {
			panic("mock out the OpenConsole method")
		},
		SpawnPlanSessionFunc: func(ctx context.Context, beadID string, projName string, mainRepoPath string, w io.Writer) error {
			panic("mock out the SpawnPlanSession method")
		},
		SpawnWorkOrchestratorFunc: func(ctx context.Context, workID string, projName string, workDir string, friendlyName string, w io.Writer) error {
			panic("mock out the SpawnWorkOrchestrator method")
		},
		TerminateWorkTabsFunc: func(ctx context.Context, workID string, projName string, w io.Writer) error {
			panic("mock out the TerminateWorkTabs method")
		},
	}

	// use mockedOrchestratorManager in code that requires OrchestratorManager
	// and then make assertions.

}

func (*OrchestratorManagerMock) EnsureWorkOrchestrator

func (mock *OrchestratorManagerMock) EnsureWorkOrchestrator(ctx context.Context, workID string, projName string, workDir string, friendlyName string, w io.Writer) (bool, error)

EnsureWorkOrchestrator calls EnsureWorkOrchestratorFunc.

func (*OrchestratorManagerMock) EnsureWorkOrchestratorCalls

func (mock *OrchestratorManagerMock) EnsureWorkOrchestratorCalls() []struct {
	Ctx          context.Context
	WorkID       string
	ProjName     string
	WorkDir      string
	FriendlyName string
	W            io.Writer
}

EnsureWorkOrchestratorCalls gets all the calls that were made to EnsureWorkOrchestrator. Check the length with:

len(mockedOrchestratorManager.EnsureWorkOrchestratorCalls())

func (*OrchestratorManagerMock) OpenClaudeSession

func (mock *OrchestratorManagerMock) OpenClaudeSession(ctx context.Context, workID string, projName string, workDir string, friendlyName string, hooksEnv []string, cfg *project.Config, w io.Writer) error

OpenClaudeSession calls OpenClaudeSessionFunc.

func (*OrchestratorManagerMock) OpenClaudeSessionCalls

func (mock *OrchestratorManagerMock) OpenClaudeSessionCalls() []struct {
	Ctx          context.Context
	WorkID       string
	ProjName     string
	WorkDir      string
	FriendlyName string
	HooksEnv     []string
	Cfg          *project.Config
	W            io.Writer
}

OpenClaudeSessionCalls gets all the calls that were made to OpenClaudeSession. Check the length with:

len(mockedOrchestratorManager.OpenClaudeSessionCalls())

func (*OrchestratorManagerMock) OpenConsole

func (mock *OrchestratorManagerMock) OpenConsole(ctx context.Context, workID string, projName string, workDir string, friendlyName string, hooksEnv []string, w io.Writer) error

OpenConsole calls OpenConsoleFunc.

func (*OrchestratorManagerMock) OpenConsoleCalls

func (mock *OrchestratorManagerMock) OpenConsoleCalls() []struct {
	Ctx          context.Context
	WorkID       string
	ProjName     string
	WorkDir      string
	FriendlyName string
	HooksEnv     []string
	W            io.Writer
}

OpenConsoleCalls gets all the calls that were made to OpenConsole. Check the length with:

len(mockedOrchestratorManager.OpenConsoleCalls())

func (*OrchestratorManagerMock) SpawnPlanSession

func (mock *OrchestratorManagerMock) SpawnPlanSession(ctx context.Context, beadID string, projName string, mainRepoPath string, w io.Writer) error

SpawnPlanSession calls SpawnPlanSessionFunc.

func (*OrchestratorManagerMock) SpawnPlanSessionCalls

func (mock *OrchestratorManagerMock) SpawnPlanSessionCalls() []struct {
	Ctx          context.Context
	BeadID       string
	ProjName     string
	MainRepoPath string
	W            io.Writer
}

SpawnPlanSessionCalls gets all the calls that were made to SpawnPlanSession. Check the length with:

len(mockedOrchestratorManager.SpawnPlanSessionCalls())

func (*OrchestratorManagerMock) SpawnWorkOrchestrator

func (mock *OrchestratorManagerMock) SpawnWorkOrchestrator(ctx context.Context, workID string, projName string, workDir string, friendlyName string, w io.Writer) error

SpawnWorkOrchestrator calls SpawnWorkOrchestratorFunc.

func (*OrchestratorManagerMock) SpawnWorkOrchestratorCalls

func (mock *OrchestratorManagerMock) SpawnWorkOrchestratorCalls() []struct {
	Ctx          context.Context
	WorkID       string
	ProjName     string
	WorkDir      string
	FriendlyName string
	W            io.Writer
}

SpawnWorkOrchestratorCalls gets all the calls that were made to SpawnWorkOrchestrator. Check the length with:

len(mockedOrchestratorManager.SpawnWorkOrchestratorCalls())

func (*OrchestratorManagerMock) TerminateWorkTabs

func (mock *OrchestratorManagerMock) TerminateWorkTabs(ctx context.Context, workID string, projName string, w io.Writer) error

TerminateWorkTabs calls TerminateWorkTabsFunc.

func (*OrchestratorManagerMock) TerminateWorkTabsCalls

func (mock *OrchestratorManagerMock) TerminateWorkTabsCalls() []struct {
	Ctx      context.Context
	WorkID   string
	ProjName string
	W        io.Writer
}

TerminateWorkTabsCalls gets all the calls that were made to TerminateWorkTabs. Check the length with:

len(mockedOrchestratorManager.TerminateWorkTabsCalls())

type PlanWorkTasksResult

type PlanWorkTasksResult struct {
	TasksCreated int
}

PlanWorkTasksResult contains the result of planning work tasks.

type RemoveBeadsResult

type RemoveBeadsResult struct {
	BeadsRemoved int
}

RemoveBeadsResult contains the result of removing beads from a work.

type RunWorkAutoResult

type RunWorkAutoResult struct {
	WorkID              string
	EstimateTaskCreated bool
	OrchestratorSpawned bool
}

RunWorkAutoResult contains the result of running work in auto mode.

type RunWorkOptions

type RunWorkOptions struct {
	UsePlan       bool
	ForceEstimate bool
}

RunWorkOptions contains options for running work.

type RunWorkResult

type RunWorkResult struct {
	WorkID              string
	TasksCreated        int
	OrchestratorSpawned bool
}

RunWorkResult contains the result of running work.

type WorkService

type WorkService struct {
	DB                  *db.DB
	Git                 git.Operations
	Worktree            worktree.Operations
	GitHubClient        github.ClientInterface
	BeadsReader         beads.Reader
	BeadsCLI            beads.CLI
	OrchestratorManager OrchestratorManager
	TaskPlanner         task.Planner
	NameGenerator       names.Generator
	Config              *project.Config
	ProjectRoot         string // Root directory of the project
	MainRepoPath        string // Path to the main repository
	BeadsDir            string // Path to beads directory
}

WorkService provides work operations with injectable dependencies. This enables both CLI and TUI to share the same tested core logic, and allows integration testing without external dependencies.

func NewWorkService

func NewWorkService(proj *project.Project) *WorkService

NewWorkService creates a WorkService with production dependencies from a project.

func NewWorkServiceWithDeps

func NewWorkServiceWithDeps(deps WorkServiceDeps) *WorkService

NewWorkServiceWithDeps creates a WorkService with explicitly provided dependencies. This is the preferred constructor for testing.

func (*WorkService) AddBeads

func (s *WorkService) AddBeads(ctx context.Context, workID string, beadIDs []string) (*AddBeadsToWorkResult, error)

AddBeads adds beads to an existing work. This is the core logic for adding beads that can be called from both the CLI and TUI. Each bead is added as its own group (no grouping).

func (*WorkService) CreateBeadFromPR

func (s *WorkService) CreateBeadFromPR(ctx context.Context, metadata *github.PRMetadata, opts *CreateBeadOptions) (*CreateBeadResult, error)

CreateBeadFromPR creates a bead from PR metadata. This allows users to optionally track imported PRs in the beads system.

func (*WorkService) CreateEstimateTaskFromWorkBeads

func (s *WorkService) CreateEstimateTaskFromWorkBeads(ctx context.Context, workID string, w io.Writer) error

CreateEstimateTaskFromWorkBeads creates an estimate task from unassigned work beads. This is used in --auto mode where the full automated workflow includes estimation. After the estimate task completes, handlePostEstimation creates implement tasks.

func (*WorkService) CreateWorkAsyncWithOptions

func (s *WorkService) CreateWorkAsyncWithOptions(ctx context.Context, opts CreateWorkAsyncOptions) (*CreateWorkAsyncResult, error)

CreateWorkAsyncWithOptions creates a work unit asynchronously by scheduling tasks. This is the async work creation for the control plane architecture: 1. Creates work record in DB (without worktree path) 2. Schedules TaskTypeCreateWorktree task for the control plane The control plane will handle worktree creation, git push, and orchestrator spawning.

func (*WorkService) CreateWorkFromBead

CreateWorkFromBead creates a work unit from a bead, handling all common steps: 1. Expands the bead to collect all issue IDs (epics, transitive deps) 2. Creates the work asynchronously via CreateWorkAsyncWithOptions

This is the shared implementation used by both CLI and TUI. Callers are responsible for ensuring the control plane is running via control.EnsureControlPlane.

func (*WorkService) DestroyWork

func (s *WorkService) DestroyWork(ctx context.Context, workID string, w io.Writer) error

DestroyWork destroys a work unit and all its resources. This is the core work destruction logic that can be called from both the CLI and TUI. It does not perform interactive confirmation - that should be handled by the caller. Progress messages are written to the provided writer. Pass io.Discard to suppress output.

func (*WorkService) ImportPRAsync

func (s *WorkService) ImportPRAsync(ctx context.Context, opts ImportPRAsyncOptions) (*ImportPRAsyncResult, error)

ImportPRAsync imports a PR asynchronously by scheduling a control plane task. This creates the work record and schedules the import task - the actual worktree setup happens in the control plane.

func (*WorkService) PlanWorkTasks

func (s *WorkService) PlanWorkTasks(ctx context.Context, workID string, autoGroup bool, w io.Writer) (*PlanWorkTasksResult, error)

PlanWorkTasks creates tasks from unassigned beads in a work unit without spawning an orchestrator. If autoGroup is true, uses LLM complexity estimation to group beads into tasks. Otherwise, uses existing group assignments from work_beads (one task per bead or group). Progress messages are written to w. Pass io.Discard to suppress output.

func (*WorkService) RemoveBeads

func (s *WorkService) RemoveBeads(ctx context.Context, workID string, beadIDs []string) (*RemoveBeadsResult, error)

RemoveBeads removes beads from an existing work. Beads that are already assigned to a task cannot be removed.

func (*WorkService) RunWork

func (s *WorkService) RunWork(ctx context.Context, workID string, usePlan bool, w io.Writer) (*RunWorkResult, error)

RunWork creates tasks from unassigned beads and ensures an orchestrator is running. This is the core logic used by both the CLI `co run` command and the TUI. Progress messages are written to the provided writer. Pass io.Discard to suppress output.

func (*WorkService) RunWorkAuto

func (s *WorkService) RunWorkAuto(ctx context.Context, workID string, w io.Writer) (*RunWorkAutoResult, error)

RunWorkAuto creates an estimate task and spawns the orchestrator for automated workflow. This mirrors the 'co run --auto' behavior: create estimate task, let orchestrator handle estimation and create implement tasks afterward. Progress messages are written to the provided writer. Pass io.Discard to suppress output.

func (*WorkService) RunWorkWithOptions

func (s *WorkService) RunWorkWithOptions(ctx context.Context, workID string, opts RunWorkOptions, w io.Writer) (*RunWorkResult, error)

RunWorkWithOptions creates tasks from unassigned beads and ensures an orchestrator is running. Progress messages are written to the provided writer. Pass io.Discard to suppress output.

func (*WorkService) SetupWorktreeFromPR

func (s *WorkService) SetupWorktreeFromPR(ctx context.Context, repoPath, prURLOrNumber, repo, workDir, branchName string) (*github.PRMetadata, string, error)

SetupWorktreeFromPR fetches a PR's branch and creates a worktree for it. It returns the created worktree path and the PR metadata.

Parameters:

  • repoPath: Path to the main repository
  • prURLOrNumber: PR URL or number
  • repo: Repository in owner/repo format (only needed if prURLOrNumber is a number)
  • workDir: Directory where the worktree should be created (worktree will be at workDir/tree)
  • branchName: Name to use for the local branch (if empty, uses the PR's branch name)

The function: 1. Fetches PR metadata to get branch information 2. Fetches the PR's head ref using GitHub's refs/pull/<n>/head 3. Creates a worktree at workDir/tree from the fetched branch

type WorkServiceDeps

type WorkServiceDeps struct {
	DB                  *db.DB
	Git                 git.Operations
	Worktree            worktree.Operations
	GitHubClient        github.ClientInterface
	BeadsReader         beads.Reader
	BeadsCLI            beads.CLI
	OrchestratorManager OrchestratorManager
	TaskPlanner         task.Planner
	NameGenerator       names.Generator
	Config              *project.Config
	ProjectRoot         string
	MainRepoPath        string
	BeadsDir            string
}

WorkServiceDeps contains all dependencies for a WorkService. Used for testing to inject mocks for all dependencies.

Jump to

Keyboard shortcuts

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