Documentation
¶
Index ¶
- func AppendSection(content, newSection string) string
- func HasSection(content, heading string) bool
- func IsValidMarkdownWithFrontmatter(content string) bool
- 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 AgentResultInfo
- type AgentStatus
- type ContentGenerator
- type ResultDeliverer
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 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 AgentResultInfo ¶
type AgentResultInfo struct {
Status AgentStatus
Output string // human-readable summary or result body
Message string // error or status message
}
AgentResultInfo holds the minimum fields a ContentGenerator needs from any agent result.
type AgentStatus ¶
type AgentStatus string
AgentStatus represents the outcome status of an agent task.
const ( // AgentStatusDone indicates the task completed successfully. AgentStatusDone AgentStatus = "done" // AgentStatusFailed indicates the task failed. AgentStatusFailed AgentStatus = "failed" // AgentStatusNeedsInput indicates the task requires additional user input. AgentStatusNeedsInput AgentStatus = "needs_input" )
type ContentGenerator ¶
type ContentGenerator interface {
Generate(ctx context.Context, originalContent string, result 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.
type ResultDeliverer ¶
type ResultDeliverer interface {
DeliverResult(ctx context.Context, result AgentResultInfo) error
}
ResultDeliverer publishes an agent result back to the task controller.
func NewFileResultDeliverer ¶
func NewFileResultDeliverer(generator ContentGenerator, filePath string) ResultDeliverer
NewFileResultDeliverer creates a 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, ) ResultDeliverer
NewKafkaResultDeliverer creates a 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 NewNoopResultDeliverer ¶
func NewNoopResultDeliverer() ResultDeliverer
NewNoopResultDeliverer creates a ResultDeliverer that does nothing.