extension

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package extension provides hooks (before/after tool call), skill loading, and MCP tool integration for the pi-go agent.

Index

Constants

This section is empty.

Variables

View Source
var SkillTemplate string

Functions

func BuildAfterToolCallbacks

func BuildAfterToolCallbacks(hooks []HookConfig) []llmagent.AfterToolCallback

BuildAfterToolCallbacks converts HookConfigs with event "after_tool" into ADK AfterToolCallback functions.

func BuildBeforeToolCallbacks

func BuildBeforeToolCallbacks(hooks []HookConfig) []llmagent.BeforeToolCallback

BuildBeforeToolCallbacks converts HookConfigs with event "before_tool" into ADK BeforeToolCallback functions.

func BuildMCPToolsets

func BuildMCPToolsets(servers []MCPServerConfig) ([]tool.Toolset, error)

BuildMCPToolsets creates ADK Toolsets from MCP server configurations. Each server is launched as a subprocess using CommandTransport. Servers that fail to initialize are logged and skipped rather than failing the entire batch.

Types

type AuditMode added in v0.0.10

type AuditMode string

AuditMode controls how skill loading handles audit findings.

const (
	// AuditBlock blocks skills with critical findings (default).
	AuditBlock AuditMode = "block"
	// AuditWarn loads all skills but logs warnings for critical findings.
	AuditWarn AuditMode = "warn"
	// AuditSkip skips scanning entirely (backward compat for tests).
	AuditSkip AuditMode = "skip"
)

type HookConfig

type HookConfig struct {
	// Event is "before_tool" or "after_tool".
	Event string `json:"event"`
	// Command is the shell command to execute.
	Command string `json:"command"`
	// Tools optionally restricts this hook to specific tool names.
	// If empty, the hook fires for all tools.
	Tools []string `json:"tools,omitempty"`
	// Timeout in seconds for hook execution. Default: 10.
	Timeout int `json:"timeout,omitempty"`
}

HookConfig defines a shell command hook that runs before or after tool calls.

type LoadOptions added in v0.0.10

type LoadOptions struct {
	AuditMode AuditMode
}

LoadOptions controls skill loading behavior.

type MCPServerConfig

type MCPServerConfig struct {
	Name    string   `json:"name"`
	Command string   `json:"command"`
	Args    []string `json:"args"`
}

MCPServerConfig matches the config.MCPServer structure.

type Skill

type Skill struct {
	// Name is the skill's identifier (derived from directory name).
	Name string
	// Description is a one-line description from frontmatter.
	Description string
	// Instruction is the markdown body (the system prompt to inject).
	Instruction string
	// Tools lists tool names this skill is allowed to use (from frontmatter).
	Tools []string
}

Skill represents a loaded skill from a SKILL.md file.

func FindSkill

func FindSkill(skills []Skill, name string) (Skill, bool)

FindSkill looks up a skill by name from a slice of loaded skills.

func LoadSkills

func LoadSkills(dirs ...string) ([]Skill, error)

LoadSkills discovers and loads skills from the given directories. It searches for <dir>/<skill-name>/SKILL.md subdirectories. Later directories override earlier ones (project overrides global). Skills with critical audit findings are blocked when AuditMode is "block" (default).

func LoadSkillsWithOptions added in v0.0.10

func LoadSkillsWithOptions(opts LoadOptions, dirs ...string) ([]Skill, error)

LoadSkillsWithOptions discovers and loads skills with configurable audit behavior.

Jump to

Keyboard shortcuts

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