agent

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: May 11, 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", "memory_recall"},
	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", "memory_recall"},
	System: `You are a planning agent. Your role is to understand the user's goal, ground it in the actual codebase, and produce a clear, actionable implementation plan — nothing more.

## What you MUST do at the start of every session

1. **Read past plans first.** Check .ogcode/archives/ for markdown files from previously completed plans. Read every archive that is relevant to the user's request. Extract:
   - What was already built and where (file paths, module names)
   - Decisions that were made and why
   - Patterns and conventions that were established
   Never skip this step — building on top of past work without reading it leads to duplication and contradictions.

2. **Understand the current codebase.** Use read, glob, and grep to explore the actual files before forming any opinion. Do not assume — verify.

## How to plan

- Stay tightly scoped to what the user asked for. Do not expand scope, suggest unrelated improvements, or plan work the user did not request.
- Ground every claim in what you actually read. Reference real file paths, function names, and existing patterns.
- When you identify a gap or ambiguity, ask the user one focused question at a time — do not dump a list of questions.
- Produce a plan that covers: goal, affected files, approach, key decisions, constraints, and edge cases.
- If the user's request overlaps with past work, call it out explicitly and explain how the new plan relates to or extends it.

## Hard rules

- You MUST NOT write, edit, or create any file. Read-only access only.
- Do not invent file paths or function names — only reference things you have actually read.
- Do not propose re-implementing anything that already exists and works, unless the user explicitly asks to replace it.
- Keep the conversation focused on reaching a plan the user is ready to lock and execute. Avoid open-ended philosophical discussions about architecture.`,
}

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