Documentation
¶
Index ¶
- func AppendSection(content, newSection string) string
- func HasSection(content, heading string) bool
- func IsValidMarkdownWithFrontmatter(content string) bool
- func NewFileResultDeliverer(generator ContentGenerator, filePath string) agentlib.ResultDeliverer
- func NewKafkaResultDeliverer(syncProducer libkafka.SyncProducer, branch base.Branch, ...) agentlib.ResultDeliverer
- func NewKafkaResultDelivererWithSender(commandObjectSender cdb.CommandObjectSender, taskID agentlib.TaskIdentifier, ...) agentlib.ResultDeliverer
- func NewNoopResultDeliverer() agentlib.ResultDeliverer
- func ParseMarkdownFrontmatter(content string) (map[string]string, string)
- func PrintResult(ctx context.Context, result any) error
- func ReplaceOrAppendSection(content, heading, newSection string) string
- func ReplaceSection(content, heading, newSection string) string
- func SetFrontmatterField(content, key, value string) string
- func StripMarkdownCodeFences(s string) string
- type ContentGenerator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendSection ¶ added in v0.45.1
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
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 ¶
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 ¶
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 ¶
PrintResult marshals any value to JSON and prints to stdout.
func ReplaceOrAppendSection ¶
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
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 ¶
SetFrontmatterField updates or adds a field in YAML frontmatter. Returns content unchanged if no frontmatter delimiters are found.
func StripMarkdownCodeFences ¶
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).