Documentation
¶
Overview ¶
Package agent provides a reusable framework for building Claude-powered CLI tools.
The framework is designed to be composable, allowing users to import packages and wire together custom CLI applications. It provides:
- Multi-provider support (Anthropic, Z.AI, Synthetic) - Automatic input detection and processing (URLs, files, globs, text) - Flexible output formatting (JSON, Markdown, text) - Type-safe tool registration - CLI scaffolding with cobra
Example usage:
import "github.com/dotcommander/agent-framework/app"
func main() {
a := app.New("myapp", "1.0.0",
app.WithSystemPrompt("You are a helpful assistant"),
app.WithModel("claude-sonnet-4-20250514"),
)
a.Run()
}
Index ¶
- Constants
- Variables
- type Action
- type AgentLoop
- type App
- type Client
- type Config
- type Feedback
- type Handler
- type LoopConfig
- type LoopContext
- type LoopRunner
- type LoopState
- type Querier
- type Result
- type StreamingQuerier
- type Subagent
- type SubagentConfig
- type SubagentContext
- type SubagentExecutor
- type SubagentExecutorFunc
- type SubagentManager
- type SubagentOption
- type SubagentResult
- type Tool
Constants ¶
const Version = "1.0.0"
Version is the framework version.
Variables ¶
var ( // NewApp creates a new application. NewApp = app.New // NewTool creates a new tool. NewTool = tools.NewTool )
Convenience constructors
var ( // WithSystemPrompt sets the system prompt. WithSystemPrompt = app.WithSystemPrompt // WithModel sets the AI model. WithModel = app.WithModel // WithProvider sets the AI provider. WithProvider = app.WithProvider // WithTool adds a tool. WithTool = app.WithTool // WithRunFunc sets a custom run function. WithRunFunc = app.WithRunFunc )
Convenience options
var ( // NewLoopRunner creates a loop runner. NewLoopRunner = app.NewLoopRunner // NewSimpleLoop creates a configurable simple loop. NewSimpleLoop = app.NewSimpleLoop // DefaultLoopConfig returns sensible loop defaults. DefaultLoopConfig = app.DefaultLoopConfig )
Agent Loop constructors
var ( // WithGatherFunc sets context gathering function. WithGatherFunc = app.WithGatherFunc // WithDecideFunc sets action decision function. WithDecideFunc = app.WithDecideFunc // WithActionFunc sets action execution function. WithActionFunc = app.WithActionFunc // WithVerifyFunc sets verification function. WithVerifyFunc = app.WithVerifyFunc // WithContinueFunc sets continuation check function. WithContinueFunc = app.WithContinueFunc )
SimpleLoop configuration options
var ( // NewSubagentManager creates a subagent coordinator. NewSubagentManager = app.NewSubagentManager // DefaultSubagentConfig returns sensible subagent defaults. DefaultSubagentConfig = app.DefaultSubagentConfig )
Subagent constructors
var ( // WithSubagentPrompt sets the subagent's system prompt. WithSubagentPrompt = app.WithSubagentPrompt // WithSubagentTools sets available tools. WithSubagentTools = app.WithSubagentTools // WithSubagentState sets initial state. WithSubagentState = app.WithSubagentState // WithSubagentMessages sets initial messages. WithSubagentMessages = app.WithSubagentMessages // WithSubagentMaxTokens sets the token limit. WithSubagentMaxTokens = app.WithSubagentMaxTokens )
Subagent options
var ( // FilterResults filters subagent results by success. FilterResults = app.FilterResults // MergeResults combines outputs from multiple results. MergeResults = app.MergeResults // AggregateTokens sums token usage across results. AggregateTokens = app.AggregateTokens )
Subagent result utilities
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client is the AI client interface (alias for StreamingQuerier). Deprecated: Use Querier or StreamingQuerier for narrower contracts.
type Handler ¶
Handler is a tool handler function.
func TypedHandler ¶
TypedHandler creates a type-safe tool handler. Use this with NewTool for type-safe tools.
Example:
handler := agent.TypedHandler(func(ctx context.Context, in MyInput) (MyOutput, error) { ... })
tool := agent.NewTool("name", "desc", schema, handler)
type LoopContext ¶
type LoopContext = app.LoopContext
LoopContext holds gathered context for an iteration.
type StreamingQuerier ¶ added in v0.3.0
type StreamingQuerier = client.StreamingQuerier
StreamingQuerier extends Querier with streaming support.
type SubagentConfig ¶
type SubagentConfig = app.SubagentConfig
SubagentConfig configures subagent behavior.
type SubagentContext ¶
type SubagentContext = app.SubagentContext
SubagentContext holds isolated context for a subagent.
type SubagentExecutor ¶
type SubagentExecutor = app.SubagentExecutor
SubagentExecutor defines how to run a subagent.
type SubagentExecutorFunc ¶
type SubagentExecutorFunc = app.SubagentExecutorFunc
SubagentExecutorFunc is a function adapter.
type SubagentManager ¶
type SubagentManager = app.SubagentManager
SubagentManager coordinates multiple subagents.
type SubagentOption ¶
type SubagentOption = app.SubagentOption
SubagentOption configures a subagent.
type SubagentResult ¶
type SubagentResult = app.SubagentResult
SubagentResult contains the outcome of a subagent's work.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package agent provides a convenience layer for building AI agents.
|
Package agent provides a convenience layer for building AI agents. |
|
Package app provides the main application structure.
|
Package app provides the main application structure. |
|
Package cli provides CLI scaffolding utilities.
|
Package cli provides CLI scaffolding utilities. |
|
Package client provides a clean wrapper around the Claude SDK client.
|
Package client provides a clean wrapper around the Claude SDK client. |
|
cmd
|
|
|
agent
command
Package main demonstrates the agent CLI framework.
|
Package main demonstrates the agent CLI framework. |
|
Package config provides configuration types and functional options for agent applications.
|
Package config provides configuration types and functional options for agent applications. |
|
examples
|
|
|
advanced
command
Package main demonstrates advanced features of the agent framework.
|
Package main demonstrates advanced features of the agent framework. |
|
codegen
command
Package main demonstrates code generation output formatting.
|
Package main demonstrates code generation output formatting. |
|
evaluation
command
Package main demonstrates hierarchical evaluation.
|
Package main demonstrates hierarchical evaluation. |
|
loop
command
Package main demonstrates the Agent Loop pattern.
|
Package main demonstrates the Agent Loop pattern. |
|
mcp
command
Package main demonstrates MCP (Model Context Protocol) server creation.
|
Package main demonstrates MCP (Model Context Protocol) server creation. |
|
quick
command
Package main demonstrates the agent convenience layer.
|
Package main demonstrates the agent convenience layer. |
|
search
command
Package main demonstrates semantic search capabilities.
|
Package main demonstrates semantic search capabilities. |
|
state
command
Package main demonstrates file system state tracking.
|
Package main demonstrates file system state tracking. |
|
subagents
command
Package main demonstrates parallel subagent execution.
|
Package main demonstrates parallel subagent execution. |
|
validation
command
Package main demonstrates the validation rules system.
|
Package main demonstrates the validation rules system. |
|
Package input provides input detection and processing.
|
Package input provides input detection and processing. |
|
internal
|
|
|
conv
Package conv provides type conversion utilities.
|
Package conv provides type conversion utilities. |
|
pathutil
Package pathutil provides shared path security utilities.
|
Package pathutil provides shared path security utilities. |
|
Package output provides output formatting and dispatching.
|
Package output provides output formatting and dispatching. |
|
Package search provides code search and retrieval capabilities.
|
Package search provides code search and retrieval capabilities. |
|
Package state provides state tracking and persistence.
|
Package state provides state tracking and persistence. |
|
Package tools provides the MCP client implementation.
|
Package tools provides the MCP client implementation. |
|
schema
Package schema provides JSON Schema generation from Go types.
|
Package schema provides JSON Schema generation from Go types. |
|
Package validation provides rules-based output validation.
|
Package validation provides rules-based output validation. |
|
Package verification provides output verification capabilities.
|
Package verification provides output verification capabilities. |