suggest

package
v0.23.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPrompt

func DefaultPrompt() string

DefaultPrompt returns the default suggestion prompt template.

func LoadPrompt

func LoadPrompt() string

LoadPrompt loads the prompt template from the extension's namespaced directory, creating the default if missing.

func Register

func Register(e *sdk.Extension)

Register wires the suggest extension into a shared SDK extension.

Types

type Config

type Config struct {
	Model       string        `yaml:"model"`
	MaxTokens   int           `yaml:"max_tokens"`
	Timeout     time.Duration `yaml:"timeout"`
	Cooldown    int           `yaml:"cooldown"`
	Enabled     bool          `yaml:"enabled"`
	TriggerMode string        `yaml:"trigger_mode"`
}

Config holds suggestion settings.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default configuration.

func LoadConfig

func LoadConfig() Config

LoadConfig loads config from ~/.config/piglet/suggest.yaml, creating defaults if missing.

type ProjectContext

type ProjectContext struct {
	GitStatus     string // "clean", "dirty", "no-repo"
	ModifiedFiles []string
	LastTool      string
	LastError     bool
}

ProjectContext holds context about the current project state.

func GatherContext

func GatherContext(cwd string, turn TurnData) ProjectContext

GatherContext collects project context from git and turn data.

type Suggester

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

Suggester generates next-prompt suggestions based on conversation context.

func NewSuggester

func NewSuggester(cfg Config, prompt string, ext *sdk.Extension) *Suggester

NewSuggester creates a new suggester with the given config.

func (*Suggester) Generate

func (s *Suggester) Generate(ctx context.Context, turn TurnData, projCtx ProjectContext) (string, error)

Generate creates a suggestion based on turn data and project context.

func (*Suggester) IncrementTurn

func (s *Suggester) IncrementTurn()

IncrementTurn increments the turn counter (called on each turn even if not suggesting).

func (*Suggester) ResetCooldown

func (s *Suggester) ResetCooldown()

ResetCooldown resets the cooldown counter after a suggestion is made.

func (*Suggester) ShouldSuggest

func (s *Suggester) ShouldSuggest() bool

ShouldSuggest checks if a suggestion should be generated for this turn.

type ToolResult

type ToolResult struct {
	ToolName   string `json:"tool_name"`
	ToolCallID string `json:"tool_call_id"`
	IsError    bool   `json:"is_error"`
	Content    []struct {
		Type string `json:"type"`
		Text string `json:"text"`
	} `json:"content"`
}

ToolResult represents a tool result from the turn.

type TurnData

type TurnData struct {
	Assistant   json.RawMessage `json:"Assistant"`
	ToolResults []ToolResult    `json:"ToolResults"`
}

TurnData represents the relevant data from an EventTurnEnd, parsed from JSON.

func (TurnData) HasError

func (t TurnData) HasError() bool

HasError returns true if any tool result was an error.

func (TurnData) ToolNames

func (t TurnData) ToolNames() []string

ToolNames returns the list of tool names from tool results.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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