insight

package
v0.22.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ValidAgentNames = []string{
	"claude",
	"codex",
	"copilot",
	"gemini",
	"kiro",
}

ValidAgentNames lists the supported insight agent names in display order. ValidAgents is a lookup set derived from it.

View Source
var ValidAgents = func() map[string]bool {
	m := make(map[string]bool, len(ValidAgentNames))
	for _, name := range ValidAgentNames {
		m[name] = true
	}
	return m
}()

ValidAgents is the set of supported insight agent names.

Functions

func BuildPrompt

func BuildPrompt(
	ctx context.Context,
	database db.Store,
	req GenerateRequest,
) (string, error)

BuildPrompt queries sessions for the given date and assembles a prompt for the AI agent.

Types

type GenerateFunc

type GenerateFunc func(
	ctx context.Context, agent, prompt string,
) (Result, error)

GenerateFunc is the signature for insight generation, allowing tests to substitute a stub.

type GenerateRequest

type GenerateRequest struct {
	Type     string
	DateFrom string
	DateTo   string
	Project  string
	Prompt   string
}

GenerateRequest describes what insight to generate.

type GenerateStreamFunc added in v0.10.0

type GenerateStreamFunc func(
	ctx context.Context, agent, prompt string, onLog LogFunc,
) (Result, error)

GenerateStreamFunc is like GenerateFunc but includes a log callback for streaming stdout/stderr events.

type LogEvent added in v0.10.0

type LogEvent struct {
	Stream string `json:"stream"` // stdout|stderr
	Line   string `json:"line"`
}

LogEvent represents one log line emitted by an insight agent process.

type LogFunc added in v0.10.0

type LogFunc func(LogEvent)

LogFunc receives real-time log events from the agent subprocess.

type Result

type Result struct {
	Content string
	Agent   string
	Model   string
}

Result holds the output from an AI agent invocation.

func Generate

func Generate(
	ctx context.Context, agent, prompt string,
) (Result, error)

Generate invokes an AI agent CLI to generate an insight. The agent parameter selects which CLI to use (claude, codex, gemini). The prompt is passed via stdin.

func GenerateStream added in v0.10.0

func GenerateStream(
	ctx context.Context, agent, prompt string, onLog LogFunc,
) (Result, error)

GenerateStream invokes an AI agent CLI to generate an insight while optionally streaming process logs.

Jump to

Keyboard shortcuts

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