agent

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BreakdownAgent = Agent{
	ID:          "breakdown",
	Name:        "Breakdown",
	Description: "Task breakdown agent — reads a locked plan and produces structured task definitions",
	Tools:       []string{"bash", "read", "glob", "grep", "submit_task_breakdown"},
	System: `You are a task breakdown agent. You will be given a locked plan conversation between a user and a planning agent. Your job is to analyze the plan and produce a structured task breakdown.

Read the codebase as needed to understand the files, patterns, and architecture mentioned in the plan. Then call the submit_task_breakdown tool with the complete task breakdown.

Each task object MUST have these fields:
- "title": string — a concise imperative title (e.g., "Add authentication middleware")
- "description": string — detailed implementation notes referencing specific files, functions, and patterns from the codebase
- "dependencies": array of integers — 0-based indices of tasks this task depends on (empty array if none)
- "effort": "S" | "M" | "L" | "XL" — estimated effort (S=tiny, M=medium, L=large, XL=extra-large)
- "complexity": "low" | "medium" | "high" — implementation complexity
- "orderIndex": integer — suggested execution order starting at 0

Rules:
- Each task must be independently implementable in its own git branch
- Order tasks so dependencies appear before dependents
- Scope tasks to be completable in one sitting where possible
- Reference actual file paths and code patterns from the project
- Consider edge cases and error handling in descriptions
- Do NOT include a task for "setting up the project" or "understanding the codebase" — assume the developer is familiar with the existing code`,
}

BreakdownAgent produces structured task definitions from a locked plan conversation.

View Source
var BuildAgent = Agent{
	ID:          "build",
	Name:        "Build",
	Description: "Full-access coding agent",
	Tools:       []string{"bash", "read", "write", "edit", "glob", "grep"},
	System: "You are a coding agent executing a task in a dedicated git worktree. You can read, write, and edit files, run commands, and search the codebase.\n\n" +
		"When working on a task:\n" +
		"1. Read the relevant files to understand the existing code before making changes.\n" +
		"2. Implement the required changes — make focused, minimal edits.\n" +
		"3. After implementing, test your changes if possible (run lint, tests, or build commands).\n" +
		"4. Stage and commit ALL your changes before finishing:\n" +
		"   git add -A && git commit -m 'descriptive message'\n" +
		"   You MUST commit — uncommitted changes will be lost after the task completes.\n" +
		"5. If you encounter errors, fix them before finishing.\n\n" +
		"Be thorough but focused. Only implement what the task requires — don't add unrelated features or refactors.",
}

BuildAgent is the default full-access coding agent.

View Source
var PlanAgent = Agent{
	ID:          "plan",
	Name:        "Plan",
	Description: "Planning agent — reads and understands code, plans changes but never writes",
	Tools:       []string{"bash", "read", "glob", "grep"},
	System: `You are a planning agent. Your job is to understand the user's problem and codebase,
then collaboratively plan a solution. You MUST NOT write or modify any code. You can:
- Read files to understand the codebase
- Search and navigate the project structure
- Discuss architecture, approach, and trade-offs with the user
- Produce detailed implementation plans

When the user is satisfied with the plan, they will break it into tasks for execution.
Be thorough: understand existing patterns, identify affected files, consider edge cases.`,
}

PlanAgent is the read-only planning agent — it can understand and plan but never writes code.

Functions

func BreakdownPrompt

func BreakdownPrompt(messages []*session.MessageWithParts, archivePaths []string) string

BreakdownPrompt constructs the user message for the breakdown agent from the plan conversation. archivePaths contains filesystem paths to previously completed plan markdown files for this project. Only the paths are mentioned — the agent reads them via its file tools if needed.

func LoadAgentMD

func LoadAgentMD(dir string) string

LoadAgentMD discovers and loads AGENT.md files by walking from dir up to the filesystem root. Files are returned in root-to-leaf order (outermost first), so that closer/leaf files appear later in the concatenated result and naturally take precedence for the LLM.

Missing files are silently skipped. Permission or read errors are logged as warnings and the file is skipped.

Types

type Agent

type Agent struct {
	ID          string
	Name        string
	Description string
	Tools       []string
	System      string
}

Agent defines an agent configuration with available tools and system prompt.

func GetAgent

func GetAgent(name string) Agent

GetAgent returns the agent by name, defaulting to BuildAgent.

func (*Agent) HasTool

func (a *Agent) HasTool(toolID string) bool

type LoopRunner

type LoopRunner struct {
	Store           *session.Store
	Bus             *bus.Bus
	Registry        *provider.Registry
	DefaultProvider provider.Provider
	Tools           *tool.Registry
	Dir             string
	MaxSteps        int
	Memory          *memory.Memory
	MCP             *mcp.Client
}

LoopRunner orchestrates the agent loop for a session.

func (*LoopRunner) RunLoop

func (lr *LoopRunner) RunLoop(ctx context.Context, sessionID session.SessionID, agentName string) error

RunLoop executes the core agent loop: prompt -> stream -> tools -> loop back.

type TaskDefinition

type TaskDefinition struct {
	Title        string `json:"title"`
	Description  string `json:"description"`
	Dependencies []int  `json:"dependencies"`
	Effort       string `json:"effort"`
	Complexity   string `json:"complexity"`
	OrderIndex   int    `json:"orderIndex"`
}

TaskDefinition represents a single task parsed from the breakdown agent's JSON output.

func ParseTasks

func ParseTasks(text string) ([]TaskDefinition, error)

ParseTasks extracts and parses the task definitions from the breakdown agent's response text. It handles cases where the LLM wraps the JSON in markdown code fences or adds preamble.

Jump to

Keyboard shortcuts

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