Documentation
¶
Index ¶
- func BuildEstimatePrompt(taskID string, beadList []beads.Bead) string
- func BuildLogAnalysisPrompt(params LogAnalysisParams) string
- func BuildPRPrompt(taskID string, workID string, branchName string, baseBranch string) string
- func BuildPlanPrompt(beadID string) string
- func BuildReviewPrompt(taskID string, workID string, branchName string, baseBranch string, ...) string
- func BuildTaskPrompt(taskID string, beadList []beads.Bead, branchName, baseBranch string) string
- func BuildUpdatePRDescriptionPrompt(taskID string, workID string, prURL string, branchName string, ...) string
- func EnsureWorkOrchestrator(ctx context.Context, database *db.DB, workID string, projectName string, ...) (bool, error)
- func FormatTabName(prefix, workID, friendlyName string) string
- func OpenClaudeSession(ctx context.Context, workID string, projectName string, workDir string, ...) error
- func OpenConsole(ctx context.Context, workID string, projectName string, workDir string, ...) error
- func PlanTabName(beadID string) string
- func RunPlanSession(ctx context.Context, beadID string, workDir string, stdin io.Reader, ...) error
- func SessionNameForProject(projectName string) string
- func SpawnPlanSession(ctx context.Context, beadID string, projectName string, mainRepoPath string, ...) error
- func SpawnWorkOrchestrator(ctx context.Context, workID string, projectName string, workDir string, ...) error
- func TabExists(ctx context.Context, sessionName, tabName string) bool
- func TerminateWorkTabs(ctx context.Context, workID string, projectName string, w io.Writer) error
- type CLIRunner
- type ClaudeRunnerMock
- type DefaultOrchestratorManager
- func (m *DefaultOrchestratorManager) EnsureWorkOrchestrator(ctx context.Context, workID, projName, workDir, friendlyName string, ...) (bool, error)
- func (m *DefaultOrchestratorManager) SpawnWorkOrchestrator(ctx context.Context, workID, projName, workDir, friendlyName string, ...) error
- func (m *DefaultOrchestratorManager) TerminateWorkTabs(ctx context.Context, workID, projName string, w io.Writer) error
- type LogAnalysisParams
- type OrchestratorManager
- type OrchestratorManagerMock
- func (mock *OrchestratorManagerMock) EnsureWorkOrchestrator(ctx context.Context, workID string, projName string, workDir string, ...) (bool, error)
- func (mock *OrchestratorManagerMock) EnsureWorkOrchestratorCalls() []struct{ ... }
- func (mock *OrchestratorManagerMock) SpawnWorkOrchestrator(ctx context.Context, workID string, projName string, workDir string, ...) error
- func (mock *OrchestratorManagerMock) SpawnWorkOrchestratorCalls() []struct{ ... }
- func (mock *OrchestratorManagerMock) TerminateWorkTabs(ctx context.Context, workID string, projName string, w io.Writer) error
- func (mock *OrchestratorManagerMock) TerminateWorkTabsCalls() []struct{ ... }
- type Runner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildEstimatePrompt ¶
BuildEstimatePrompt builds a prompt for complexity estimation of beads.
func BuildLogAnalysisPrompt ¶
func BuildLogAnalysisPrompt(params LogAnalysisParams) string
BuildLogAnalysisPrompt builds a prompt for Claude-based CI log analysis.
func BuildPRPrompt ¶
BuildPRPrompt builds a prompt for PR creation.
func BuildPlanPrompt ¶
BuildPlanPrompt builds a prompt for planning an issue.
func BuildReviewPrompt ¶
func BuildReviewPrompt(taskID string, workID string, branchName string, baseBranch string, rootIssueID string) string
BuildReviewPrompt builds a prompt for code review.
func BuildTaskPrompt ¶
BuildTaskPrompt builds a prompt for a task with multiple beads.
func BuildUpdatePRDescriptionPrompt ¶
func BuildUpdatePRDescriptionPrompt(taskID string, workID string, prURL string, branchName string, baseBranch string) string
BuildUpdatePRDescriptionPrompt builds a prompt for updating a PR description.
func EnsureWorkOrchestrator ¶
func EnsureWorkOrchestrator(ctx context.Context, database *db.DB, 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. The database parameter is used to check orchestrator heartbeat status.
func FormatTabName ¶
FormatTabName formats a tab name with an optional friendly name. If friendlyName is not empty, formats as "prefix-workID (friendlyName)", otherwise just "prefix-workID".
func OpenClaudeSession ¶
func 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.
func OpenConsole ¶
func 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.
func PlanTabName ¶
PlanTabName returns the zellij tab name for a bead's planning session. This mirrors db.TabNameForBead but is in the claude package to avoid circular imports.
func RunPlanSession ¶
func RunPlanSession(ctx context.Context, beadID string, workDir string, stdin io.Reader, stdout, stderr io.Writer, cfg *project.Config) error
RunPlanSession runs an interactive Claude session for planning an issue. This launches Claude with the plan prompt and connects stdin/stdout/stderr for interactive use. The config parameter controls Claude settings like --dangerously-skip-permissions.
func SessionNameForProject ¶
SessionNameForProject returns the zellij session name for a specific project.
func SpawnPlanSession ¶
func 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.
func SpawnWorkOrchestrator ¶
func 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.
func TerminateWorkTabs ¶
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.
Types ¶
type ClaudeRunnerMock ¶
type ClaudeRunnerMock struct {
// RunFunc mocks the Run method.
RunFunc func(ctx context.Context, database *db.DB, taskID string, prompt string, workDir string, cfg *project.Config) error
// contains filtered or unexported fields
}
ClaudeRunnerMock is a mock implementation of Runner.
func TestSomethingThatUsesRunner(t *testing.T) {
// make and configure a mocked Runner
mockedRunner := &ClaudeRunnerMock{
RunFunc: func(ctx context.Context, database *db.DB, taskID string, prompt string, workDir string, cfg *project.Config) error {
panic("mock out the Run method")
},
}
// use mockedRunner in code that requires Runner
// and then make assertions.
}
type DefaultOrchestratorManager ¶
type DefaultOrchestratorManager struct {
// contains filtered or unexported fields
}
DefaultOrchestratorManager is the default implementation of OrchestratorManager. It wraps the package-level functions and holds the database reference needed for orchestrator heartbeat checking.
func (*DefaultOrchestratorManager) EnsureWorkOrchestrator ¶
func (m *DefaultOrchestratorManager) EnsureWorkOrchestrator(ctx context.Context, workID, projName, workDir, friendlyName string, w io.Writer) (bool, error)
EnsureWorkOrchestrator implements OrchestratorManager.
func (*DefaultOrchestratorManager) SpawnWorkOrchestrator ¶
func (m *DefaultOrchestratorManager) SpawnWorkOrchestrator(ctx context.Context, workID, projName, workDir, friendlyName string, w io.Writer) error
SpawnWorkOrchestrator implements OrchestratorManager.
func (*DefaultOrchestratorManager) TerminateWorkTabs ¶
func (m *DefaultOrchestratorManager) TerminateWorkTabs(ctx context.Context, workID, projName string, w io.Writer) error
TerminateWorkTabs implements OrchestratorManager.
type LogAnalysisParams ¶
type LogAnalysisParams struct {
TaskID string
WorkID string
BranchName string
RootIssueID string
WorkflowName string
JobName string
LogContent string
}
LogAnalysisParams contains parameters for building a log analysis prompt.
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
}
OrchestratorManager provides operations for managing work orchestrators. 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.
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)
// 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")
},
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) 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 Runner ¶
type Runner interface {
// Run executes Claude directly in the current terminal (fork/exec).
Run(ctx context.Context, database *db.DB, taskID string, prompt string, workDir string, cfg *project.Config) error
}
Runner defines the interface for running Claude. This abstraction enables testing without spawning the actual claude CLI.