delivery

package
v0.56.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: BSD-2-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendSection added in v0.45.1

func AppendSection(content, newSection string) string

AppendSection appends newSection to content, ensuring a single blank line separator and exactly one trailing newline in the result.

func HasSection added in v0.45.1

func HasSection(content, heading string) bool

HasSection reports whether content contains at least one line that matches heading at line-start. A match requires the line to equal heading exactly, or to start with heading followed by a space or tab. Substrings like "## Results" do NOT match "## Result".

func IsValidMarkdownWithFrontmatter

func IsValidMarkdownWithFrontmatter(content string) bool

IsValidMarkdownWithFrontmatter checks that the string has valid YAML frontmatter delimiters. The content must start with "---" followed by a newline and have a closing "---" on its own line.

func NewFileResultDeliverer

func NewFileResultDeliverer(generator ContentGenerator, filePath string) agentlib.ResultDeliverer

NewFileResultDeliverer creates a agentlib.ResultDeliverer that writes results to a task file. The generator produces the complete updated markdown; the deliverer writes it to disk.

func NewKafkaResultDeliverer

func NewKafkaResultDeliverer(
	syncProducer libkafka.SyncProducer,
	branch base.Branch,
	taskID agentlib.TaskIdentifier,
	originalContent string,
	generator ContentGenerator,
	currentDateTime libtime.CurrentDateTimeGetter,
) agentlib.ResultDeliverer

NewKafkaResultDeliverer creates a agentlib.ResultDeliverer that publishes task updates to Kafka. taskID must be non-empty; if empty, use NewNoopResultDeliverer instead. originalContent is the original task markdown; the generator produces the complete updated content.

func NewKafkaResultDelivererWithSender added in v0.53.1

func NewKafkaResultDelivererWithSender(
	commandObjectSender cdb.CommandObjectSender,
	taskID agentlib.TaskIdentifier,
	originalContent string,
	generator ContentGenerator,
	currentDateTime libtime.CurrentDateTimeGetter,
) agentlib.ResultDeliverer

NewKafkaResultDelivererWithSender creates a agentlib.ResultDeliverer that publishes task updates via the given sender. This constructor is primarily useful for testing.

func NewNoopResultDeliverer

func NewNoopResultDeliverer() agentlib.ResultDeliverer

NewNoopResultDeliverer creates a agentlib.ResultDeliverer that does nothing.

func ParseMarkdownFrontmatter

func ParseMarkdownFrontmatter(content string) (map[string]string, string)

ParseMarkdownFrontmatter splits a markdown document with YAML frontmatter into a string map and the body. Returns empty map and full content if no frontmatter. Values are converted to strings: arrays become fmt representation, nested objects become fmt representation.

func PrintResult

func PrintResult(ctx context.Context, result any) error

PrintResult marshals any value to JSON and prints to stdout.

func ReplaceOrAppendSection

func ReplaceOrAppendSection(content, heading, newSection string) string

ReplaceOrAppendSection replaces every section matching heading with newSection, or appends newSection if no matching section exists. The result always contains exactly one section with this heading.

func ReplaceSection added in v0.45.1

func ReplaceSection(content, heading, newSection string) string

ReplaceSection removes every section whose heading line matches heading (line-start match) and appends newSection once at the end. If no section matches, behaves identically to AppendSection.

func SetFrontmatterField

func SetFrontmatterField(content, key, value string) string

SetFrontmatterField updates or adds a field in YAML frontmatter. Returns content unchanged if no frontmatter delimiters are found.

func StripMarkdownCodeFences

func StripMarkdownCodeFences(s string) string

StripMarkdownCodeFences removes surrounding ``` code fences from a string if present.

Types

type ContentGenerator

type ContentGenerator interface {
	Generate(
		ctx context.Context,
		originalContent string,
		result agentlib.AgentResultInfo,
	) (string, error)
}

ContentGenerator produces a complete updated task markdown document from the original content and agent result. The returned string must be valid markdown with YAML frontmatter.

func NewFallbackContentGenerator

func NewFallbackContentGenerator() ContentGenerator

NewFallbackContentGenerator creates a ContentGenerator that uses deterministic string concatenation.

func NewPassthroughContentGenerator added in v0.54.0

func NewPassthroughContentGenerator() ContentGenerator

NewPassthroughContentGenerator creates a ContentGenerator that returns result.Output verbatim (with status/phase frontmatter applied on top).

Used by the new agent framework (lib.NewAgent / lib.StepRunner): the step mutates a parsed Markdown via task.AddSection / ReplaceSection and the runner re-serializes the full task into result.Output. The deliverer must NOT splice the output into a "## Result" section — it must publish the agent-produced content directly.

Status/phase frontmatter is still applied here so file delivery sets status: completed / phase: done on success without each agent having to mutate the frontmatter map manually. The Kafka deliverer overrides status/phase again after this generator runs (same end state).

func NewSectionContentGenerator added in v0.54.0

func NewSectionContentGenerator(heading string) ContentGenerator

NewSectionContentGenerator creates a ContentGenerator that writes its output under a parameterized markdown heading (e.g. "## Plan", "## Review"). On agentlib.AgentStatusFailed it writes a "## Failure" section instead, regardless of the configured heading — the failure-section convention is repo-wide, not phase-specific.

Use this for phase-aware agents whose phases write distinct sections (planning → ## Plan, execution → ## Result, review → ## Review).

Jump to

Keyboard shortcuts

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