Files
David Gageot 2ad2d0e9b4 feat(hooks): add add_context builtin for dependency-free template context injection
Adds a new add_context builtin hook that renders Go text/template arguments
against hook input and joins non-blank results as additional_context. No
external dependencies (no jq, no shell) are required.

- Renders each arg as an independent text/template against the hook input
- Joins non-blank results with newlines as additional_context
- Strict: template parse and execution errors propagate and follow on_error
- Plain-text output only; no re-evaluation or command execution
- Registered alongside existing builtins in pkg/hooks/builtins

Updates schema descriptions, types.go comments, hooks reference docs,
tips guide (updates session ID tip from jq command to add_context builtin),
canonical examples/hooks.yaml, and adds standalone examples/context_hooks.yaml.
Unit and runtime test coverage included.
2026-09-09 08:58:48 +02:00

14 lines
408 B
YAML

agents:
root:
model: anthropic/claude-sonnet-4-5
description: Assistant with dependency-free session context.
instruction: You are a helpful assistant.
hooks:
session_start:
- type: builtin
command: add_context
args:
- "Current session ID: {{ .SessionID }}"
- "Agent: {{ .AgentName }}"
- "Working directory: {{ .Cwd }}"