Documentation
¶
Index ¶
- func CollectIssueIDsForAutomatedWorkflow(ctx context.Context, beadID string, beadsClient *beads.Client) ([]string, error)
- func DestroyWork(ctx context.Context, proj *project.Project, workID string, w io.Writer) error
- func EnsureUniqueBranchName(ctx context.Context, gitOps git.Operations, repoPath, baseName string) (string, error)
- func GenerateBranchNameFromIssue(issue *beads.Bead) string
- func GenerateBranchNameFromIssues(issues []*beads.Bead) string
- func ParseBeadIDs(beadIDStr string) []string
- type AddBeadsToWorkResult
- type CreateBeadOptions
- type CreateBeadResult
- type CreateWorkAsyncOptions
- type CreateWorkAsyncResult
- type ImportPRAsyncOptions
- type ImportPRAsyncResult
- type PRImporter
- func (p *PRImporter) CreateBeadFromPR(ctx context.Context, metadata *github.PRMetadata, opts *CreateBeadOptions) (*CreateBeadResult, error)
- func (p *PRImporter) FetchPRMetadata(ctx context.Context, prURLOrNumber, repo string) (*github.PRMetadata, error)
- func (p *PRImporter) SetupWorktreeFromPR(ctx context.Context, repoPath, prURLOrNumber, repo, workDir, branchName string) (*github.PRMetadata, string, error)
- type PlanWorkTasksResult
- type RemoveBeadsResult
- type RunWorkAutoResult
- type RunWorkOptions
- type RunWorkResult
- type WorkService
- func (s *WorkService) AddBeads(ctx context.Context, workID string, beadIDs []string) (*AddBeadsToWorkResult, error)
- func (s *WorkService) AddBeadsInternal(ctx context.Context, workID string, beadIDs []string) error
- func (s *WorkService) CreateEstimateTaskFromWorkBeads(ctx context.Context, workID string, w io.Writer) error
- func (s *WorkService) CreateWorkAsync(ctx context.Context, branchName, baseBranch, rootIssueID string, auto bool) (*CreateWorkAsyncResult, error)
- func (s *WorkService) CreateWorkAsyncWithOptions(ctx context.Context, opts CreateWorkAsyncOptions) (*CreateWorkAsyncResult, error)
- func (s *WorkService) DestroyWork(ctx context.Context, workID string, w io.Writer) error
- func (s *WorkService) PlanWorkTasks(ctx context.Context, workID string, autoGroup bool, w io.Writer) (*PlanWorkTasksResult, error)
- func (s *WorkService) RemoveBeads(ctx context.Context, workID string, beadIDs []string) (*RemoveBeadsResult, error)
- func (s *WorkService) RunWork(ctx context.Context, workID string, usePlan bool, w io.Writer) (*RunWorkResult, error)
- func (s *WorkService) RunWorkAuto(ctx context.Context, workID string, w io.Writer) (*RunWorkAutoResult, error)
- func (s *WorkService) RunWorkWithOptions(ctx context.Context, workID string, opts RunWorkOptions, w io.Writer) (*RunWorkResult, error)
- type WorkServiceDeps
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CollectIssueIDsForAutomatedWorkflow ¶
func CollectIssueIDsForAutomatedWorkflow(ctx context.Context, beadID string, beadsClient *beads.Client) ([]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 DestroyWork ¶
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 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 ¶
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 ¶
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 ¶
ParseBeadIDs parses a comma-delimited string of bead IDs into a slice. It trims whitespace from each ID and filters out empty strings.
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 ¶
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 ImportPRAsyncOptions ¶
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.
func ImportPRAsync ¶
func ImportPRAsync(ctx context.Context, proj *project.Project, 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.
type PRImporter ¶
type PRImporter struct {
// contains filtered or unexported fields
}
PRImporter handles importing PRs into work units.
func NewPRImporter ¶
func NewPRImporter(client github.ClientInterface) *PRImporter
NewPRImporter creates a new PR importer with default operations.
func NewPRImporterWithOps ¶
func NewPRImporterWithOps(client github.ClientInterface, gitOps git.Operations, worktreeOps worktree.Operations) *PRImporter
NewPRImporterWithOps creates a new PR importer with custom operations (for testing).
func (*PRImporter) CreateBeadFromPR ¶
func (p *PRImporter) 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 (*PRImporter) FetchPRMetadata ¶
func (p *PRImporter) FetchPRMetadata(ctx context.Context, prURLOrNumber, repo string) (*github.PRMetadata, error)
FetchPRMetadata is a convenience method that just fetches PR metadata without creating a worktree.
func (*PRImporter) SetupWorktreeFromPR ¶
func (p *PRImporter) 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 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 ¶
RunWorkAutoResult contains the result of running work in auto mode.
type RunWorkOptions ¶
RunWorkOptions contains options for running work.
type RunWorkResult ¶
RunWorkResult contains the result of running work.
type WorkService ¶
type WorkService struct {
DB *db.DB
Git git.Operations
Worktree worktree.Operations
BeadsReader beads.Reader
BeadsCLI beads.CLI
OrchestratorManager claude.OrchestratorManager
TaskPlanner task.Planner
NameGenerator names.Generator
Config *project.Config
ProjectRoot string // Root directory of the project
MainRepoPath string // Path to the main repository
}
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) AddBeadsInternal ¶
AddBeadsInternal adds beads to work_beads table without validation.
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) CreateWorkAsync ¶
func (s *WorkService) CreateWorkAsync(ctx context.Context, branchName, baseBranch, rootIssueID string, auto bool) (*CreateWorkAsyncResult, error)
CreateWorkAsync 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) CreateWorkAsyncWithOptions ¶
func (s *WorkService) CreateWorkAsyncWithOptions(ctx context.Context, opts CreateWorkAsyncOptions) (*CreateWorkAsyncResult, error)
CreateWorkAsyncWithOptions creates a work unit asynchronously with the given options. This is similar to CreateWorkAsync but supports additional options like using an existing branch.
func (*WorkService) DestroyWork ¶
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) 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.
type WorkServiceDeps ¶
type WorkServiceDeps struct {
DB *db.DB
Git git.Operations
Worktree worktree.Operations
BeadsReader beads.Reader
BeadsCLI beads.CLI
OrchestratorManager claude.OrchestratorManager
TaskPlanner task.Planner
NameGenerator names.Generator
Config *project.Config
ProjectRoot string
MainRepoPath string
}
WorkServiceDeps contains all dependencies for a WorkService. Used for testing to inject mocks for all dependencies.