runbook

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package runbook provides a loader for customer-provided instructional files ("runbooks") using the trpc-agent-go document reader framework. Runbooks are loaded from configured file paths or directories and their content is injected into the agent's system prompt, giving customers a way to define instructions that Genie must follow (e.g., deployment procedures, coding standards, troubleshooting playbooks).

Without this package, there would be no mechanism for customers to supply structured, multi-format instructions beyond the single Agents.md file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSearchTool

func NewSearchTool(store vector.IStore) tool.Tool

NewSearchTool creates a tool that searches runbook content stored in the vector store. Runbook documents are indexed with metadata type=runbook and source=<filename>, enabling semantic search over customer-provided instructions, deployment guides, and playbooks.

func RunbookID

func RunbookID(workingDir, fullPath string) string

RunbookID returns a stable, deterministic ID for a runbook file based on its path relative to the working directory. This prevents ID collisions when files with the same name exist in different directories (e.g. ops/deploy.md vs dev/deploy.md).

Types

type Config

type Config struct {
	// Paths is a list of file paths or directories containing runbook files.
	// Both absolute and relative paths are supported. When a directory is
	// specified, all supported files within it are loaded (non-recursive).
	Paths []string `yaml:"runbook_paths,omitempty" toml:"runbook_paths,omitempty"`
}

Config holds the runbook loader configuration. Customers can specify explicit paths via config files or rely on the convention directory (.genie/runbooks/) in the working directory.

type Loader

type Loader struct {
	// contains filtered or unexported fields
}

Loader reads runbook files from the filesystem using the trpc-agent-go document reader registry. It resolves the appropriate reader for each file based on its extension and concatenates the content with per-file headers.

func NewLoader

func NewLoader(workingDirectory string, cfg Config, vectorStore vector.IStore) *Loader

NewLoader creates a new runbook Loader scoped to the given working directory and configuration. The working directory is used to resolve relative paths and to auto-discover the .genie/runbooks/ convention directory. Without this constructor, callers would need to manually assemble paths and reader selection logic.

func (*Loader) KeepWatching

func (l *Loader) KeepWatching(ctx context.Context)

func (*Loader) Load

func (l *Loader) Load(ctx context.Context) (int, error)

Load discovers all runbook files and ingests them into the vector store for semantic search via the search_runbook tool. Returns the number of files successfully ingested.

func (*Loader) LoadFiles

func (l *Loader) LoadFiles(ctx context.Context) []RunbookFile

LoadFiles reads all configured runbook files and returns them as individual RunbookFile entries. Unlike Load(), which concatenates everything into a single string for persona injection, LoadFiles preserves per-file boundaries so callers can ingest each file separately (e.g. into a vector store).

func (*Loader) WatchDirs

func (l *Loader) WatchDirs() []string

WatchDirs returns the resolved directories that should be watched for runbook file changes. It includes the convention directory and any configured directory paths.

type Runbook

type Runbook interface {
	Load(ctx context.Context) (int, error)
	KeepWatching(ctx context.Context)
}

type RunbookFile

type RunbookFile struct {
	Name    string // base filename, e.g. "deployment-guide.md"
	Path    string // absolute path to the file
	Content string // full text content of the runbook
}

RunbookFile represents a single loaded runbook with its source path and text content. Used by LoadFiles to return individual entries for vector store ingestion.

type ToolProvider

type ToolProvider struct {
	// contains filtered or unexported fields
}

ToolProvider wraps a vector IStore and satisfies the tools.ToolProviders interface so the search_runbook tool can be passed directly to tools.NewRegistry.

func NewToolProvider

func NewToolProvider(store vector.IStore) *ToolProvider

NewToolProvider creates a ToolProvider for the runbook search tool.

func (*ToolProvider) GetTools

func (p *ToolProvider) GetTools() []tool.Tool

GetTools returns the search_runbook tool.

type Watcher

type Watcher struct {
	// contains filtered or unexported fields
}

Watcher monitors runbook directories for file changes and keeps the vector store in sync. Events are debounced (500ms) and flushed in batch to avoid I/O thrashing on bulk updates.

func NewWatcher

func NewWatcher(loader *Loader, store vector.IStore, dirs []string) (*Watcher, error)

NewWatcher creates a Watcher that monitors the given directories for runbook file changes. The loader is used to read file content and the store is used to add/remove documents.

func (*Watcher) Close

func (w *Watcher) Close() error

Close stops the file system watcher.

func (*Watcher) Start

func (w *Watcher) Start(ctx context.Context)

Start begins processing file system events with debouncing. It blocks until the context is cancelled. Call this in a goroutine.

Jump to

Keyboard shortcuts

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