agent

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildSystemPrompt

func BuildSystemPrompt(ctx context.Context, pool *pgxpool.Pool, repoName string, toolNames []string) string

BuildSystemPrompt creates the context starvation system prompt.

Types

type Agent

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

Agent is the LLM-powered code intelligence agent. It delegates to a pluggable LLMProvider (Gemini, Ollama, etc.).

func NewAgent

func NewAgent(ctx context.Context, cfg AgentConfig, provCfg ProviderConfig, bridge *ToolBridge, systemPrompt string) (*Agent, error)

NewAgent creates an Agent backed by the provider selected in provCfg.

func (*Agent) Ask

func (a *Agent) Ask(ctx context.Context, question string) (string, error)

Ask answers a single question using the agentic tool-calling loop.

func (*Agent) Chat

func (a *Agent) Chat(ctx context.Context, history []ConversationMessage, message string) (string, []ConversationMessage, error)

Chat runs one turn in a multi-turn conversation and returns the updated history.

func (*Agent) Close

func (a *Agent) Close()

Close releases the underlying provider resources.

func (*Agent) GenerateDoc

func (a *Agent) GenerateDoc(ctx context.Context, systemPrompt, userPrompt string) (string, error)

GenerateDoc makes a one-shot LLM call (no tool loop) with a custom system prompt.

type AgentConfig

type AgentConfig struct {
	MaxIterations int
	Model         string
	Temperature   float32
	RepoName      string
}

AgentConfig configures the Gemini agent.

func DefaultConfig

func DefaultConfig() AgentConfig

DefaultConfig returns sensible defaults.

type ConversationMessage

type ConversationMessage struct {
	Role    string // "user" | "model"
	Content string
}

ConversationMessage is a single turn in a conversation.

type DocGenerator

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

DocGenerator orchestrates multi-step documentation generation from graph data.

func NewDocGenerator

func NewDocGenerator(agent *Agent, pool *pgxpool.Pool) *DocGenerator

NewDocGenerator creates a new DocGenerator.

func (*DocGenerator) GenerateSkillsForRepo

func (g *DocGenerator) GenerateSkillsForRepo(ctx context.Context, repoID int64, repoPath string) ([]SkillResult, error)

GenerateSkillsForRepo generates one SKILL.md per community for the given repo.

func (*DocGenerator) GenerateWiki

func (g *DocGenerator) GenerateWiki(ctx context.Context, repoID int64, outputDir string) ([]string, error)

GenerateWiki generates a full Markdown wiki from the knowledge graph.

func (*DocGenerator) GetWikiPages

func (g *DocGenerator) GetWikiPages() map[string]string

GetWikiPages returns generated pages after GenerateWiki is called.

type LLMProvider added in v0.2.0

type LLMProvider interface {
	Ask(ctx context.Context, question string) (string, error)
	Chat(ctx context.Context, history []ConversationMessage, message string) (string, []ConversationMessage, error)
	GenerateDoc(ctx context.Context, systemPrompt, userPrompt string) (string, error)
	Close()
}

LLMProvider is the interface for an LLM-backed agent provider. Each provider manages its own agentic tool-calling loop.

type ProviderConfig added in v0.2.0

type ProviderConfig struct {
	Provider    string // "gemini" (default) | "ollama" | "openai"
	GeminiKey   string
	OllamaURL   string // default: http://localhost:11434
	OllamaModel string // default: llama3.2
	// OpenAI-compatible API settings
	OpenAIBaseURL         string // e.g. "http://10.1.1.246:8001/v1"
	OpenAIAPIKey          string
	OpenAIModel           string // e.g. "qwen3.5-35b"
	OpenAIDisableThinking bool   // disable reasoning/thinking mode (e.g. Qwen3)
}

ProviderConfig selects and configures the LLM provider.

type SkillResult

type SkillResult struct {
	FilePath      string
	CommunityName string
	Content       string
}

SkillResult represents a generated SKILL.md file.

type ToolBridge

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

ToolBridge holds all tool handlers for direct invocation.

func NewToolBridge

func NewToolBridge(uc *UseCases) *ToolBridge

NewToolBridge wires all use cases into a callable tool map.

func (*ToolBridge) Execute

func (b *ToolBridge) Execute(ctx context.Context, name string, args map[string]interface{}) (string, error)

Execute runs the named tool with the given arguments.

func (*ToolBridge) ToolNames

func (b *ToolBridge) ToolNames() []string

ToolNames returns the list of registered tool names.

type ToolCall

type ToolCall struct {
	Name   string
	Args   map[string]interface{}
	Result string
}

ToolCall records an agent tool invocation.

type ToolHandler

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

ToolHandler executes a tool and returns a string result.

type UseCases

type UseCases struct {
	SearchCode     *usecase.SearchCodeUseCase
	ReadFile       *usecase.ReadFileUseCase
	FindSymbol     *usecase.FindSymbolUseCase
	FindCallers    *usecase.FindCallersUseCase
	ListEndpoints  *usecase.ListEndpointsUseCase
	GetFileSymbols *usecase.GetFileSymbolsUseCase
	ListServices   *usecase.ListServicesUseCase
	GetServiceDeps *usecase.GetServiceDepsUseCase
	GetAPIHandlers *usecase.GetAPIHandlersUseCase
}

UseCases groups all MCP use cases needed by the bridge.

Jump to

Keyboard shortcuts

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