2026-06-29 00:25:45 +00:00
# 📦 Components Reference
2026-06-30 20:40:37 +00:00
> **Detailed reference per package.** Each package has its README in `pkg/<name>/README.md` — this document is the high-level overview and how they connect.
2026-06-29 00:25:45 +00:00
2026-06-30 20:40:37 +00:00
## 📚 Packages table
2026-06-29 00:25:45 +00:00
2026-06-30 20:40:37 +00:00
| Package | Responsibility | README |
2026-06-29 00:25:45 +00:00
|---|---|---|
2026-06-30 20:40:37 +00:00
| `pkg/agent` | Iterative loop, termination, approval hooks | [`pkg/agent/README.md` ](../pkg/agent/README.md ) |
2026-06-29 00:25:45 +00:00
| `pkg/llm` | `LLMClient` interface, streaming, providers | [`pkg/llm/README.md` ](../pkg/llm/README.md ) |
| `pkg/tools` | Tool registry, JSON Schema, sandbox | [`pkg/tools/README.md` ](../pkg/tools/README.md ) |
| `pkg/persona` | Persona system, AGENTS.md discovery | [`pkg/persona/README.md` ](../pkg/persona/README.md ) |
2026-06-30 20:40:37 +00:00
| `pkg/rag` | Memory, embeddings, vector DB | [`pkg/rag/README.md` ](../pkg/rag/README.md ) |
| `pkg/config` | YAML loading, precedence | [`pkg/config/README.md` ](../pkg/config/README.md ) |
2026-06-29 00:25:45 +00:00
2026-06-30 20:40:37 +00:00
## 🗺️ How they connect
2026-06-29 00:25:45 +00:00
```
┌──────────────────┐
2026-06-30 20:40:37 +00:00
│ pkg/agent │ ← Orchestrates everything
2026-06-29 00:25:45 +00:00
│ (Loop) │
└────────┬─────────┘
│
┌────────────────────┼────────────────────┐
│ │ │
▼ ▼ ▼
┌─────────┐ ┌──────────┐ ┌──────────┐
│ pkg/llm │ │pkg/tools │ │pkg/persona│
│ (LLM │ │ (Tools + │ │ (Persona)│
│ Client) │ │ Registry)│ │ │
└────┬────┘ └────┬─────┘ └──────────┘
│ │
│ providers │ sandbox
▼ ▼
┌──────────┐ ┌────────────┐
│ adapters │ │ os.Root │
│ (OpenAI, │ │ (kernel) │
│ Anthropic│ └────────────┘
│ Ollama...)│
└──────────┘
┌─────────┐ ┌─────────┐ ┌──────────┐
│ pkg/rag │ │pkg/config│ │ examples │
│ (Memory)│ │ (YAML) │ │ (demo) │
└─────────┘ └─────────┘ └──────────┘
```
2026-06-30 20:40:37 +00:00
## 🔄 Typical usage flow
2026-06-29 00:25:45 +00:00
```go
2026-06-30 20:40:37 +00:00
// 1. Load config
2026-06-29 00:25:45 +00:00
cfg, _ := config.Load(ctx, workdir)
2026-06-30 20:40:37 +00:00
// 2. Create LLM client from config
2026-06-29 00:25:45 +00:00
llmClient, _ := llm.NewFromConfig(cfg.Provider)
2026-06-30 20:40:37 +00:00
// 3. Load persona (auto-discovers AGENTS.md)
2026-06-29 00:25:45 +00:00
p, _ := persona.Discover(ctx, workdir)
2026-06-30 20:40:37 +00:00
// 4. Create tool registry and register product-specific tools
2026-06-29 00:25:45 +00:00
registry := tools.NewRegistry()
2026-06-30 20:40:37 +00:00
// (product registers its specific tools here)
2026-06-29 00:25:45 +00:00
2026-06-30 20:40:37 +00:00
// 5. Create memory (if product uses it)
2026-06-29 00:25:45 +00:00
memory, _ := rag.NewFromConfig(cfg.RAG)
2026-06-30 20:40:37 +00:00
// 6. Create agent loop
2026-06-29 00:25:45 +00:00
loop := agent.New(agent.Config{
LLM: llmClient,
Persona: p,
Tools: registry,
Memory: memory,
Sandbox: tools.NewSandbox(workdir),
})
2026-06-30 20:40:37 +00:00
// 7. Run
resp, _ := loop.Run(ctx, "Refactor auth.go")
2026-06-29 00:25:45 +00:00
```
2026-06-30 20:40:37 +00:00
## 🎯 Decision: which package to use for what
2026-06-29 00:25:45 +00:00
2026-06-30 20:40:37 +00:00
| I need... | Use... |
2026-06-29 00:25:45 +00:00
|---|---|
2026-06-30 20:40:37 +00:00
| To call an LLM | `pkg/llm/` |
| To let the LLM invoke functions | `pkg/tools/` |
| To build the system prompt | `pkg/persona/` |
| To remember context between sessions | `pkg/rag/` |
| To configure behavior from YAML | `pkg/config/` |
| To run the complete loop (LLM + tools + memory) | `pkg/agent/` |
| To validate paths securely | `pkg/tools/sandbox/` |
2026-06-29 00:25:45 +00:00
2026-06-30 20:40:37 +00:00
## 📝 Complete examples
2026-06-29 00:25:45 +00:00
2026-06-30 20:40:37 +00:00
See [`examples/` ](../../examples/ ) — standalone examples that show common use cases.
2026-06-29 00:25:45 +00:00
2026-06-30 20:40:37 +00:00
| Example | Demonstrates |
2026-06-29 00:25:45 +00:00
|---|---|
2026-06-30 20:40:37 +00:00
| `examples/simple_chat/` | Basic chat without tools |
| `examples/chat_with_tools/` | Chat with custom tools |
| `examples/rag_qa/` | Q& A over documents |
| `examples/multi_agent/` | Sub-agent orchestration |
| `examples/streaming_ui/` | TUI integration |
2026-06-29 00:25:45 +00:00
2026-06-30 20:40:37 +00:00
> 📌 Examples are created when the codebase is implemented. For now each `pkg/*/README.md` has a minimal usage snippet.
2026-06-29 00:25:45 +00:00
2026-06-30 20:40:37 +00:00
## 🔌 Included adapters
2026-06-29 00:25:45 +00:00
### LLM Providers (`pkg/llm/providers/`)
2026-06-30 20:40:37 +00:00
| Provider | Import | Models |
2026-06-29 00:25:45 +00:00
|---|---|---|
| OpenAI | `providers/openai` | gpt-4o, gpt-4o-mini, gpt-4-turbo |
| Anthropic | `providers/anthropic` | claude-sonnet-4.5, claude-haiku-4 |
| Ollama | `providers/ollama` | llama3.1, qwen2.5, mistral |
| llama.cpp | `providers/llamacpp` | Custom GGUF models |
### Vector DBs (`pkg/rag/backends/`)
2026-06-30 20:40:37 +00:00
| Backend | Status | Notes |
2026-06-29 00:25:45 +00:00
|---|---|---|
2026-06-30 20:40:37 +00:00
| ChromaDB embedded | ✅ Stable | Default, simple API |
| Qdrant embedded | 🚧 In development | For >100k docs |
| SQLite + sqlite-vec | 📋 Planned | Zero-deps |
2026-06-29 00:25:45 +00:00
### Embeddings (`pkg/rag/embeddings/`)
2026-06-30 20:40:37 +00:00
| Provider | Models |
2026-06-29 00:25:45 +00:00
|---|---|
| Ollama | nomic-embed-text, bge-m3, mxbai-embed-large |
| Local ONNX | all-MiniLM-L6-v2 (fallback) |
2026-06-30 20:40:37 +00:00
## 🛠️ How to add a new component
2026-06-29 00:25:45 +00:00
2026-06-30 20:40:37 +00:00
**Example: add a new LLM provider**
2026-06-29 00:25:45 +00:00
```bash
mkdir -p pkg/llm/providers/myprovider
touch pkg/llm/providers/myprovider/client.go
touch pkg/llm/providers/myprovider/client_test.go
```
```go
// pkg/llm/providers/myprovider/client.go
package myprovider
import (
"context"
2026-06-29 06:22:15 +00:00
"github.com/VictorVargas/rony-llm-agent/pkg/llm"
2026-06-29 00:25:45 +00:00
)
type Client struct {
apiKey string
model string
}
func New(cfg Config) (*Client, error) {
return & Client{apiKey: cfg.APIKey, model: cfg.Model}, nil
}
func (c *Client) Generate(ctx context.Context, req llm.CompletionRequest) (llm.CompletionResponse, error) {
// implement against MyProvider API
}
func (c *Client) Stream(ctx context.Context, req llm.CompletionRequest) iter.Seq2[llm.StreamChunk, error] {
// implement
}
func (c *Client) Name() string { return "myprovider" }
func (c *Client) Capabilities() llm.ProviderCapabilities { /* ... */ }
```
2026-06-30 20:40:37 +00:00
Rules:
- ✅ Implement the complete `LLMClient` interface
- ✅ Tests with `httptest.NewServer` to mock the API
- ✅ Document in `pkg/llm/providers/myprovider/README.md` (optional but recommended)
- ✅ Register in `llm.NewFromConfig()` to be eligible via YAML
2026-06-29 00:25:45 +00:00
2026-06-30 20:40:37 +00:00
## 📖 Related documents
2026-06-29 00:25:45 +00:00
2026-06-30 20:40:37 +00:00
- [`architecture.md` ](./architecture.md ) — Architecture and core interfaces
- [`phase2.md` ](./phase2.md ) — Advanced features (MCP, full RAG, Skills, etc.)
- [Products that use this library ](https://github.com/VictorVargas )