config

package
v0.7.11 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package config parses CronFoundry manifest and skill files and resolves single-level `{{ include "..." }}` directives inside skill bodies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectSecretRefs

func CollectSecretRefs(destinations, env json.RawMessage, llmRef *string, extra ...json.RawMessage) []string

CollectSecretRefs extracts all secret names referenced from destinations JSON, env JSON, and an optional LLM secret reference. Secret references appear in the form `{ "secret": "name" }` anywhere in the JSON.

Non-string "secret" values are skipped. Results are sorted + deduplicated.

func ResolveIncludes

func ResolveIncludes(body, root string) (string, error)

ResolveIncludes replaces `{{ include "path" }}` directives with the file contents read from `root`. The directive is single-level only — included content is inserted verbatim without re-processing.

Security:

  • absolute paths are rejected
  • paths that escape `root` (via `..`) are rejected

Types

type AutoPauseConfig

type AutoPauseConfig struct {
	After int `json:"after"`
}

AutoPauseConfig controls the auto-pause-on-consecutive-failures behavior. If nil, the schedule uses the global default (DefaultAutoPauseAfter).

type Destination

type Destination struct {
	GitHubIssue *GitHubIssueDest `json:"github-issue,omitempty"`
	Slack       *WebhookDest     `json:"slack,omitempty"`
	Discord     *WebhookDest     `json:"discord,omitempty"`
	Teams       *WebhookDest     `json:"teams,omitempty"`
	HTTP        *HTTPDest        `json:"http,omitempty"`
	Email       *EmailDest       `json:"email,omitempty"`
	// When controls which run outcomes trigger this destination.
	// Valid values: "always" (default), "on_success", "on_failure".
	When string `json:"when,omitempty"`
}

func (Destination) ShouldPublish

func (d Destination) ShouldPublish(runSucceeded bool) bool

ShouldPublish returns true when the destination should fire given runSucceeded.

func (Destination) Validate

func (d Destination) Validate() error

Validate returns an error if the destination config is invalid.

type EmailDest

type EmailDest struct {
	SMTPHost       string   `json:"smtp_host"`
	SMTPPort       int      `json:"smtp_port,omitempty"` // default 587
	UsernameSecret string   `json:"username_secret"`
	PasswordSecret string   `json:"password_secret"`
	From           string   `json:"from"`
	To             []string `json:"to"`
	Subject        string   `json:"subject,omitempty"` // template.Render template; default below
	Format         string   `json:"format,omitempty"`  // "html" (default) or "text"
	Output         string   `json:"output,omitempty"`  // named output block to use; empty = full output
}

func (*EmailDest) EffectiveFormat

func (e *EmailDest) EffectiveFormat() string

func (*EmailDest) EffectiveSMTPPort

func (e *EmailDest) EffectiveSMTPPort() int

type EnvValue

type EnvValue struct {
	Literal string
	Secret  string
}

EnvValue is either a literal string or a `{ secret: name }` reference.

func (*EnvValue) UnmarshalJSON

func (e *EnvValue) UnmarshalJSON(data []byte) error

type GitHubIssueDest

type GitHubIssueDest struct {
	Repo      string   `json:"repo"`
	Title     string   `json:"title,omitempty"`
	Body      string   `json:"body,omitempty"`
	Labels    []string `json:"labels,omitempty"`
	Assignees []string `json:"assignees,omitempty"`
	Output    string   `json:"output,omitempty"` // named output block to use; empty = full output
}

type HTTPDest

type HTTPDest struct {
	URL          string            `json:"url"`
	Method       string            `json:"method,omitempty"` // default "POST"
	Secret       string            `json:"secret,omitempty"` // logical secret name; sent as Bearer token
	Headers      map[string]string `json:"headers,omitempty"`
	BodyTemplate string            `json:"body_template,omitempty"` // Go template; default sends {"output":"<output>"}
	Output       string            `json:"output,omitempty"`
}

type MCPServer

type MCPServer struct {
	Name    string   `json:"name"`
	Command string   `json:"command"`
	Args    []string `json:"args"`
}

type Manifest

type Manifest struct {
	Version int          `json:"version"`
	Skills  []SkillEntry `json:"skills"`
}

func ParseManifest

func ParseManifest(data []byte) (*Manifest, error)

func (*Manifest) FindSchedule

func (m *Manifest) FindSchedule(skillPath, scheduleName string) (*SkillEntry, *Schedule, error)

FindSchedule returns pointers to the skill and schedule matching the given coordinates, or an error if either is not found.

func (*Manifest) Validate

func (m *Manifest) Validate() error

Validate returns the first validation error found, or nil.

type Schedule

type Schedule struct {
	Name          string                         `json:"name"`
	Cron          string                         `json:"cron"`
	Timezone      string                         `json:"timezone"`
	OverlapPolicy string                         `json:"overlap_policy"`
	TimeoutSec    int                            `json:"timeout_sec"`
	Provider      string                         `json:"provider"`
	Model         string                         `json:"model"`
	MaxTurns      int                            `json:"max_turns,omitempty"`
	Destinations  []Destination                  `json:"destinations"`
	Writeback     *WritebackConfig               `json:"writeback,omitempty"`
	Env           map[string]EnvValue            `json:"env"`
	MCPEnv        map[string]map[string]EnvValue `json:"mcp_env,omitempty"`
	AutoPause     *AutoPauseConfig               `json:"auto_pause,omitempty"`
	CopilotPrefix string                         `json:"copilot_prefix,omitempty"`
}

func (*Schedule) EffectiveOverlapPolicy

func (s *Schedule) EffectiveOverlapPolicy() string

EffectiveOverlapPolicy returns the overlap policy with the default resolved. An empty OverlapPolicy in the YAML means "skip" — this method centralizes that default so callers don't need to handle both forms.

type Skill

type Skill struct {
	Frontmatter SkillFrontmatter
	Body        string
}

func ParseSkillFile

func ParseSkillFile(data []byte) (*Skill, error)

ParseSkillFile extracts the YAML frontmatter and prompt body. Frontmatter is delimited by `---\n` on its own line at the top of the file and a matching `---\n` closing line.

func (*Skill) Validate

func (s *Skill) Validate() error

Validate returns the first schema violation found, or nil.

type SkillEntry

type SkillEntry struct {
	Path      string     `json:"path"`
	Schedules []Schedule `json:"schedules"`
}

type SkillFrontmatter

type SkillFrontmatter struct {
	Name        string                    `json:"name"`
	Description string                    `json:"description"`
	ModelHint   string                    `json:"model_hint"`
	MaxTokens   int                       `json:"max_tokens"`
	MaxTurns    int                       `json:"max_turns"`
	MCPServers  []MCPServer               `json:"mcp_servers,omitempty"`
	Writeback   SkillWritebackFrontmatter `json:"writeback"`
}

type SkillWritebackFrontmatter

type SkillWritebackFrontmatter struct {
	BlockFormat string `json:"block_format"`
}

type WebhookDest

type WebhookDest struct {
	Secret   string `json:"secret"`
	Text     string `json:"text,omitempty"`
	Content  string `json:"content,omitempty"`
	Title    string `json:"title,omitempty"`
	Username string `json:"username,omitempty"`
	Format   string `json:"format,omitempty"` // "blocks" (Slack default), "text", "card" (Teams)
	Output   string `json:"output,omitempty"` // named output block to use; empty = full output
}

type WritebackConfig

type WritebackConfig struct {
	Enabled bool   `json:"enabled"`
	Path    string `json:"path"`
	Mode    string `json:"mode"`
}

Jump to

Keyboard shortcuts

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