subagent

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultScanInterval = 30 * time.Second
)

Variables

This section is empty.

Functions

func ValidateSubagent

func ValidateSubagent(subagent *Subagent) error

ValidateSubagent performs validation checks on a parsed subagent configuration

Types

type ClaudeConfig

type ClaudeConfig struct {
	Name        string `yaml:"name"`
	Description string `yaml:"description"`
	Tools       string `yaml:"tools,omitempty"` // Comma-separated list
	Model       string `yaml:"model,omitempty"` // Model override
}

ClaudeConfig represents the YAML frontmatter structure for Claude-style subagents

type CompletionAdapter

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

CompletionAdapter adapts SubagentManager to the completion.SubagentProvider interface This avoids import cycles by keeping the completion package independent

func NewCompletionAdapter

func NewCompletionAdapter(manager *SubagentManager, ensureUpToDate func()) *CompletionAdapter

NewCompletionAdapter creates a new adapter for the completion system

func (*CompletionAdapter) GetAllSubagents

func (ca *CompletionAdapter) GetAllSubagents() map[string]*completion.SubagentInfo

GetAllSubagents returns all subagents as completion.SubagentInfo

func (*CompletionAdapter) GetSubagent

func (ca *CompletionAdapter) GetSubagent(id string) (*completion.SubagentInfo, bool)

GetSubagent returns a specific subagent as completion.SubagentInfo

type RooConfig

type RooConfig struct {
	CustomModes []RooCustomMode `yaml:"customModes"`
}

RooConfig represents the top-level Roo Code configuration structure

type RooCustomMode

type RooCustomMode struct {
	Slug               string        `yaml:"slug"`
	Name               string        `yaml:"name"`
	Description        string        `yaml:"description,omitempty"`
	RoleDefinition     string        `yaml:"roleDefinition"`
	WhenToUse          string        `yaml:"whenToUse,omitempty"`
	CustomInstructions string        `yaml:"customInstructions,omitempty"`
	Groups             []interface{} `yaml:"groups"`
	Model              string        `yaml:"model,omitempty"`
}

RooCustomMode represents a single custom mode from Roo Code configuration

type RooGroupConfig

type RooGroupConfig struct {
	Group     string `yaml:"group"`
	FileRegex string `yaml:"fileRegex,omitempty"`
}

RooGroupConfig represents group configurations with optional restrictions

type SelectionResult

type SelectionResult struct {
	SubagentID string `json:"subagent_id"`
	Confidence int    `json:"confidence"` // 0-100
	Reasoning  string `json:"reasoning"`
}

SelectionResult represents the LLM's subagent selection decision

type Subagent

type Subagent struct {
	// Unified fields
	ID           string       `json:"id"`           // Unique identifier (name for Claude, slug for Roo)
	Name         string       `json:"name"`         // Display name
	Description  string       `json:"description"`  // Description of when to use this subagent
	Type         SubagentType `json:"type"`         // Configuration format type
	FilePath     string       `json:"filePath"`     // Path to configuration file
	LastModified time.Time    `json:"lastModified"` // File modification time for cache invalidation

	// System prompt content
	SystemPrompt string `json:"systemPrompt"`

	// Tool configuration
	AllowedTools []string `json:"allowedTools"` // List of allowed bish tools
	FileRegex    string   `json:"fileRegex"`    // File access restriction pattern (from Roo Code)

	// Model configuration
	Model string `json:"model"` // Model override or "inherit"

	// Source configuration for debugging/display
	SourceConfig interface{} `json:"sourceConfig,omitempty"`
}

Subagent represents a unified subagent configuration from either Claude or Roo Code formats

func ParseConfigFile

func ParseConfigFile(filePath string) ([]*Subagent, error)

ParseConfigFile detects the format and parses either Claude or Roo Code configuration

type SubagentExecutor

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

SubagentExecutor handles the execution of individual subagents

func NewSubagentExecutor

func NewSubagentExecutor(
	runner *interp.Runner,
	historyManager *history.HistoryManager,
	logger *zap.Logger,
	subagent *Subagent,
	sessionID string,
) *SubagentExecutor

NewSubagentExecutor creates a new executor for a specific subagent

func (*SubagentExecutor) Chat

func (e *SubagentExecutor) Chat(prompt string) (<-chan string, error)

Chat handles a chat interaction with the subagent

func (*SubagentExecutor) ResetChat

func (e *SubagentExecutor) ResetChat()

ResetChat resets the chat session for this subagent

type SubagentIntegration

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

SubagentIntegration handles the integration of subagents with gsh's shell system

func NewSubagentIntegration

func NewSubagentIntegration(runner *interp.Runner, history *history.HistoryManager, logger *zap.Logger, sessionID string) *SubagentIntegration

NewSubagentIntegration creates a new subagent integration instance

func (*SubagentIntegration) GetCompletionProvider

func (si *SubagentIntegration) GetCompletionProvider() completion.SubagentProvider

GetCompletionProvider returns a completion provider for the subagent system

func (*SubagentIntegration) GetManager

func (si *SubagentIntegration) GetManager() *SubagentManager

GetManager returns the subagent manager for external access

func (*SubagentIntegration) GetManagerInterface

func (si *SubagentIntegration) GetManagerInterface() SubagentManagerInterface

GetManagerInterface returns the subagent manager as an interface for external access

func (*SubagentIntegration) HandleAgentControl

func (si *SubagentIntegration) HandleAgentControl(control string) bool

HandleAgentControl processes subagent-related agent controls

func (*SubagentIntegration) HandleCommand

func (si *SubagentIntegration) HandleCommand(chatMessage string) (bool, <-chan string, *Subagent, error)

HandleCommand processes potential subagent commands and returns true if handled

type SubagentManager

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

SubagentManager handles loading, parsing, and managing subagent configurations

func NewSubagentManager

func NewSubagentManager(runner *interp.Runner, logger *zap.Logger) *SubagentManager

NewSubagentManager creates a new SubagentManager with default configuration directories

func (*SubagentManager) FindSubagentByName

func (m *SubagentManager) FindSubagentByName(name string) (*Subagent, bool)

FindSubagentByName searches for a subagent by name or partial name match

func (*SubagentManager) GetAllSubagents

func (m *SubagentManager) GetAllSubagents() map[string]*Subagent

GetAllSubagents returns all loaded subagents

func (*SubagentManager) GetSubagent

func (m *SubagentManager) GetSubagent(id string) (*Subagent, bool)

GetSubagent retrieves a subagent by ID

func (*SubagentManager) GetSubagentsSummary

func (m *SubagentManager) GetSubagentsSummary() string

GetSubagentsSummary returns a formatted summary of all loaded subagents

func (*SubagentManager) LoadSubagents

func (m *SubagentManager) LoadSubagents(logger *zap.Logger) error

LoadSubagents scans all configured directories and loads subagent configurations

func (*SubagentManager) Reload

func (m *SubagentManager) Reload(logger *zap.Logger) error

Reload reloads all subagent configurations

func (*SubagentManager) ShouldReload

func (m *SubagentManager) ShouldReload() bool

ShouldReload checks if configurations should be reloaded based on file modifications or directory changes

type SubagentManagerInterface

type SubagentManagerInterface interface {
	GetAllSubagents() map[string]*Subagent
	GetSubagent(id string) (*Subagent, bool)
	FindSubagentByName(name string) (*Subagent, bool)
}

SubagentManagerInterface defines the interface for subagent management This allows other components to access subagent information without tight coupling

type SubagentSelector

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

SubagentSelector uses LLM to intelligently select the best subagent for a given prompt

func NewSubagentSelector

func NewSubagentSelector(runner *interp.Runner, logger *zap.Logger) *SubagentSelector

NewSubagentSelector creates a new intelligent subagent selector

func (*SubagentSelector) SelectBestSubagent

func (s *SubagentSelector) SelectBestSubagent(prompt string, availableSubagents map[string]*Subagent) (*Subagent, error)

SelectBestSubagent uses LLM to determine the most appropriate subagent for the given prompt

type SubagentType

type SubagentType string

SubagentType represents the format type of the subagent configuration

const (
	ClaudeType SubagentType = "claude"
	RooType    SubagentType = "roo"
)

Jump to

Keyboard shortcuts

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