learning

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewScheduler = calibration.NewScheduler

Re-export functions for convenience

Functions

This section is empty.

Types

type ActionContext

type ActionContext struct {
	Action    string
	Target    string
	Timestamp time.Time
	Success   bool
}

ActionContext tracks recent user actions

type CalibrationConfig

type CalibrationConfig = calibration.CalibrationConfig

Type aliases for calibration package to simplify imports

type DynamicResource

type DynamicResource struct {
	URI         string      `json:"uri"`
	Name        string      `json:"name"`
	Description string      `json:"description"`
	MimeType    string      `json:"mimeType"`
	Content     interface{} `json:"content"`
}

DynamicResource represents a dynamically generated resource

type Engine

type Engine struct {
	Detector        *PatternDetector
	ProactiveEngine *ProactiveSuggestionEngine
	Calibrator      *Scheduler
	// contains filtered or unexported fields
}

Engine is the central "brain" of MCPBee, encapsulating all intelligence.

func NewEngine

func NewEngine(knowledge knowledge.Store, calibConfig CalibrationConfig) (*Engine, error)

NewEngine creates a new intelligence engine with event bus for decoupling.

func (*Engine) GetEventBus

func (e *Engine) GetEventBus() *eventbus.EventBus

GetEventBus returns the event bus for external components to publish events

func (*Engine) GetKnowledgeStore

func (e *Engine) GetKnowledgeStore() knowledge.Store

GetKnowledgeStore returns the underlying knowledge store for direct access when needed.

func (*Engine) ProcessEvent

func (e *Engine) ProcessEvent(ctx context.Context, event *events.Event)

ProcessEvent is the single entry point for all external events.

func (*Engine) PublishEvent

func (e *Engine) PublishEvent(ctx context.Context, eventType eventbus.EventType, source string, data map[string]interface{}) error

PublishEvent publishes an event to the internal event bus

func (*Engine) Start

func (e *Engine) Start(ctx context.Context)

Start begins background processes for the learning engine.

func (*Engine) Stop

func (e *Engine) Stop()

Stop gracefully shuts down the learning engine.

type ErrorContext

type ErrorContext struct {
	Error     string
	Timestamp time.Time
	File      string
	Line      int
	Resolved  bool
}

ErrorContext tracks recent errors for pattern matching

type MCPServer

type MCPServer interface {
	RegisterSessionTool(sessionID string, name string) error
	RegisterDynamicTool(name string, description string, handler ToolHandler) error
	GetProjectID() string
	GetSessionID() string
}

MCPServer interface defines the contract for MCP server interactions

type Pattern

type Pattern struct {
	ID             string                 `json:"id"`
	ErrorType      string                 `json:"error_type"`
	ErrorSignature string                 `json:"error_signature"`
	Solution       string                 `json:"solution"`
	Context        map[string]interface{} `json:"context"`
	Occurrences    int                    `json:"occurrences"`
	Confidence     float64                `json:"confidence"`
	SuccessRate    float64                `json:"success_rate"`
	LastSeen       time.Time              `json:"last_seen"`
	FirstSeen      time.Time              `json:"first_seen"`
	ProjectIDs     []string               `json:"project_ids"`
	SessionIDs     []string               `json:"session_ids"`
}

Pattern represents an identified Error→Solution pattern

type PatternDetector

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

PatternDetector identifies and tracks Error→Solution patterns with confidence scoring

func NewPatternDetector

func NewPatternDetector(knowledge knowledge.Store) *PatternDetector

NewPatternDetector creates a new pattern detector

func (*PatternDetector) DetectEmergingPatterns

func (pd *PatternDetector) DetectEmergingPatterns(ctx context.Context, projectID string) ([]*Pattern, error)

DetectEmergingPatterns identifies new patterns from recent activity

func (*PatternDetector) GetHighConfidencePatterns

func (pd *PatternDetector) GetHighConfidencePatterns(minConfidence float64) []*Pattern

GetHighConfidencePatterns returns patterns with high confidence

func (*PatternDetector) GetPattern

func (pd *PatternDetector) GetPattern(patternID string) *Pattern

GetPattern returns a specific pattern by ID

func (*PatternDetector) GetSuggestedFix

func (pd *PatternDetector) GetSuggestedFix(ctx context.Context, errorMsg string, projectID string) (*Pattern, error)

GetSuggestedFix returns the best fix for an error based on patterns

func (*PatternDetector) GetTopPatterns

func (pd *PatternDetector) GetTopPatterns(n int) []*Pattern

GetTopPatterns returns the top N patterns by confidence

func (*PatternDetector) RecordErrorSolution

func (pd *PatternDetector) RecordErrorSolution(ctx context.Context, errorMsg, solution string, success bool, metadata map[string]interface{}) error

RecordErrorSolution records an error and its solution

func (*PatternDetector) UpdatePatternSuccess

func (pd *PatternDetector) UpdatePatternSuccess(patternID string, success bool)

UpdatePatternSuccess updates a pattern's success rate after application

type ProactiveSuggestionEngine

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

ProactiveSuggestionEngine anticipates user needs and surfaces relevant knowledge

func NewProactiveSuggestionEngine

func NewProactiveSuggestionEngine(knowledge knowledge.Store) *ProactiveSuggestionEngine

NewProactiveSuggestionEngine creates a new proactive suggestion engine

func (*ProactiveSuggestionEngine) GetSuggestions

func (pse *ProactiveSuggestionEngine) GetSuggestions() []*Suggestion

GetSuggestions returns current relevant suggestions

func (*ProactiveSuggestionEngine) ProcessEvent

func (pse *ProactiveSuggestionEngine) ProcessEvent(ctx context.Context, event *events.Event)

ProcessEvent processes an event from the stream consumer (single source of truth)

func (*ProactiveSuggestionEngine) RecordAction

func (pse *ProactiveSuggestionEngine) RecordAction(action, target string, success bool)

RecordAction records a user action for context tracking

func (*ProactiveSuggestionEngine) RecordError

func (pse *ProactiveSuggestionEngine) RecordError(errorMsg string, file string, line int)

RecordError records an error for pattern analysis

func (*ProactiveSuggestionEngine) SetResourceProvider

func (pse *ProactiveSuggestionEngine) SetResourceProvider(rp ResourceProvider)

SetResourceProvider sets the resource provider for the engine

func (*ProactiveSuggestionEngine) SetServer

func (pse *ProactiveSuggestionEngine) SetServer(server MCPServer)

SetServer sets the MCP server reference for the engine

func (*ProactiveSuggestionEngine) UpdateContext

func (pse *ProactiveSuggestionEngine) UpdateContext(ctx WorkContext)

UpdateContext updates the current working context

type ResourceProvider

type ResourceProvider interface {
	GetResources() map[string]*DynamicResource
	GetResource(uri string) (*DynamicResource, error)
	UpdateSessionID(sessionID string)
}

ResourceProvider interface defines the contract for resource providers

type Scheduler

type Scheduler = calibration.Scheduler

Type aliases for calibration package to simplify imports

type Suggestion

type Suggestion struct {
	ID          string                 `json:"id"`
	Type        string                 `json:"type"` // "tool", "resource", "pattern", "tip"
	Priority    float64                `json:"priority"`
	Title       string                 `json:"title"`
	Description string                 `json:"description"`
	Action      interface{}            `json:"action"` // Tool to create, resource to surface, etc.
	Reason      string                 `json:"reason"`
	Confidence  float64                `json:"confidence"`
	Context     map[string]interface{} `json:"context"`
	ExpiresAt   time.Time              `json:"expires_at"`
}

Suggestion represents a proactive suggestion

type ToolHandler

type ToolHandler func(ctx context.Context, args map[string]interface{}) (*ToolResult, error)

ToolHandler is a function that handles tool execution

type ToolResult

type ToolResult struct {
	Content     interface{} `json:"content"`
	IsError     bool        `json:"isError,omitempty"`
	Annotations []string    `json:"annotations,omitempty"`
}

ToolResult represents the result of a tool execution

type WorkContext

type WorkContext struct {
	ProjectID    string
	SessionID    string
	CurrentFile  string
	CurrentTask  string
	Language     string
	Framework    string
	LastActivity time.Time
}

WorkContext represents the current working context

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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