parser

package
v0.25.1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IncludeDirectivePattern = regexp.MustCompile(`^(?:@(?:include|import)(\?)?\s+(.+)|{{#import(\?)?\s*:?\s*(.+?)\s*}})$`)

IncludeDirectivePattern matches @include, @import (deprecated), or {{#import (new) directives The colon after #import is optional and ignored if present

View Source
var LegacyIncludeDirectivePattern = regexp.MustCompile(`^@(?:include|import)(\?)?\s+(.+)$`)

LegacyIncludeDirectivePattern matches only the deprecated @include and @import directives

Functions

func EnsureLocalhostDomains added in v0.8.3

func EnsureLocalhostDomains(domains []string) []string

EnsureLocalhostDomains ensures that localhost and 127.0.0.1 are always included in the allowed domains list for Playwright, even when custom domains are specified Includes port variations to allow all ports on localhost and 127.0.0.1

func EnsureToolsSection added in v0.8.3

func EnsureToolsSection(frontmatter map[string]any) map[string]any

EnsureToolsSection ensures the tools section exists in frontmatter and returns it

func ExpandIncludes

func ExpandIncludes(content, baseDir string, extractTools bool) (string, error)

ExpandIncludes recursively expands @include and @import directives until no more remain This matches the bash expand_includes function behavior

func ExpandIncludesForEngines added in v0.5.1

func ExpandIncludesForEngines(content, baseDir string) ([]string, error)

ExpandIncludesForEngines recursively expands @include and @import directives to extract engine configurations

func ExpandIncludesForSafeOutputs added in v0.14.1

func ExpandIncludesForSafeOutputs(content, baseDir string) ([]string, error)

ExpandIncludesForSafeOutputs recursively expands @include and @import directives to extract safe-outputs configurations

func ExpandIncludesWithManifest added in v0.14.1

func ExpandIncludesWithManifest(content, baseDir string, extractTools bool) (string, []string, error)

ExpandIncludesWithManifest recursively expands @include and @import directives and returns list of included files

func ExtractFrontmatterString

func ExtractFrontmatterString(content string) (string, error)

ExtractFrontmatterString extracts only the YAML frontmatter as a string This matches the bash extract_frontmatter function

func ExtractMarkdown

func ExtractMarkdown(filePath string) (string, error)

ExtractMarkdown extracts markdown content from a file (excluding frontmatter) This matches the bash extract_markdown function

func ExtractMarkdownContent

func ExtractMarkdownContent(content string) (string, error)

ExtractMarkdownContent extracts only the markdown content (excluding frontmatter) This matches the bash extract_markdown function

func ExtractMarkdownSection

func ExtractMarkdownSection(content, sectionName string) (string, error)

ExtractMarkdownSection extracts a specific section from markdown content Supports H1-H3 headers and proper nesting (matches bash implementation)

func ExtractWorkflowNameFromMarkdown

func ExtractWorkflowNameFromMarkdown(filePath string) (string, error)

ExtractWorkflowNameFromMarkdown extracts workflow name from first H1 header This matches the bash extract_workflow_name_from_markdown function exactly

func ExtractYAMLError

func ExtractYAMLError(err error, frontmatterLineOffset int) (line int, column int, message string)

ExtractYAMLError extracts line and column information from YAML parsing errors frontmatterLineOffset is the line number where the frontmatter content begins in the document (1-based) This allows proper line number reporting when frontmatter is not at the beginning of the document

func ExtractYamlChunk

func ExtractYamlChunk(yamlContent, key string) (string, error)

ExtractYamlChunk extracts a specific YAML section with proper indentation handling This matches the bash extract_yaml_chunk function exactly

func GetGitHubToken

func GetGitHubToken() (string, error)

GetGitHubToken attempts to get GitHub token from environment or gh CLI

func MergeTools

func MergeTools(base, additional map[string]any) (map[string]any, error)

MergeTools merges two neutral tool configurations. Only supports merging arrays and maps for neutral tools (bash, web-fetch, web-search, edit, mcp-*). Removes all legacy Claude tool merging logic.

func ProcessImportsFromFrontmatter added in v0.14.1

func ProcessImportsFromFrontmatter(frontmatter map[string]any, baseDir string) (mergedTools string, mergedEngines []string, err error)

ProcessImportsFromFrontmatter processes imports field from frontmatter Returns merged tools and engines from imported files

func ProcessIncludes

func ProcessIncludes(content, baseDir string, extractTools bool) (string, error)

ProcessIncludes processes @include, @import (deprecated), and {{#import: directives in markdown content This matches the bash process_includes function behavior

func ProcessIncludesForEngines added in v0.5.1

func ProcessIncludesForEngines(content, baseDir string) ([]string, string, error)

ProcessIncludesForEngines processes import directives to extract engine configurations

func ProcessIncludesForSafeOutputs added in v0.14.1

func ProcessIncludesForSafeOutputs(content, baseDir string) ([]string, string, error)

ProcessIncludesForSafeOutputs processes import directives to extract safe-outputs configurations

func StripANSI

func StripANSI(s string) string

StripANSI removes all ANSI escape sequences from a string This handles: - CSI (Control Sequence Introducer) sequences: \x1b[... - OSC (Operating System Command) sequences: \x1b]...\x07 or \x1b]...\x1b\\ - Simple escape sequences: \x1b followed by a single character

func UpdateWorkflowFrontmatter added in v0.8.3

func UpdateWorkflowFrontmatter(workflowPath string, updateFunc func(frontmatter map[string]any) error, verbose bool) error

UpdateWorkflowFrontmatter updates the frontmatter of a workflow file using a callback function

func ValidateIncludedFileFrontmatterWithSchema

func ValidateIncludedFileFrontmatterWithSchema(frontmatter map[string]any) error

ValidateIncludedFileFrontmatterWithSchema validates included file frontmatter using JSON schema

func ValidateIncludedFileFrontmatterWithSchemaAndLocation

func ValidateIncludedFileFrontmatterWithSchemaAndLocation(frontmatter map[string]any, filePath string) error

ValidateIncludedFileFrontmatterWithSchemaAndLocation validates included file frontmatter with file location info

func ValidateMCPConfigWithSchema

func ValidateMCPConfigWithSchema(mcpConfig map[string]any, toolName string) error

ValidateMCPConfigWithSchema validates MCP configuration using JSON schema

func ValidateMainWorkflowFrontmatterWithSchema

func ValidateMainWorkflowFrontmatterWithSchema(frontmatter map[string]any) error

ValidateMainWorkflowFrontmatterWithSchema validates main workflow frontmatter using JSON schema

func ValidateMainWorkflowFrontmatterWithSchemaAndLocation

func ValidateMainWorkflowFrontmatterWithSchemaAndLocation(frontmatter map[string]any, filePath string) error

ValidateMainWorkflowFrontmatterWithSchemaAndLocation validates main workflow frontmatter with file location info

Types

type FrontmatterResult

type FrontmatterResult struct {
	Frontmatter map[string]any
	Markdown    string
	// Additional fields for error context
	FrontmatterLines []string // Original frontmatter lines for error context
	FrontmatterStart int      // Line number where frontmatter starts (1-based)
}

FrontmatterResult holds parsed frontmatter and markdown content

func ExtractFrontmatterFromContent

func ExtractFrontmatterFromContent(content string) (*FrontmatterResult, error)

ExtractFrontmatterFromContent parses YAML frontmatter from markdown content string

type ImportDirectiveMatch added in v0.14.1

type ImportDirectiveMatch struct {
	IsOptional bool
	Path       string
	IsLegacy   bool
	Original   string
}

ImportDirectiveMatch holds the parsed components of an import directive

func ParseImportDirective added in v0.14.1

func ParseImportDirective(line string) *ImportDirectiveMatch

ParseImportDirective parses an import directive and returns its components

type ImportsResult added in v0.14.1

type ImportsResult struct {
	MergedTools       string   // Merged tools configuration from all imports
	MergedMCPServers  string   // Merged mcp-servers configuration from all imports
	MergedEngines     []string // Merged engine configurations from all imports
	MergedSafeOutputs []string // Merged safe-outputs configurations from all imports
	MergedMarkdown    string   // Merged markdown content from all imports
	MergedSteps       string   // Merged steps configuration from all imports
	MergedRuntimes    string   // Merged runtimes configuration from all imports
	MergedServices    string   // Merged services configuration from all imports
	MergedNetwork     string   // Merged network configuration from all imports
	ImportedFiles     []string // List of imported file paths (for manifest)
}

ImportsResult holds the result of processing imports from frontmatter

func ProcessImportsFromFrontmatterWithManifest added in v0.14.1

func ProcessImportsFromFrontmatterWithManifest(frontmatter map[string]any, baseDir string) (*ImportsResult, error)

ProcessImportsFromFrontmatterWithManifest processes imports field from frontmatter Returns result containing merged tools, engines, markdown content, and list of imported files

type JSONPathInfo added in v0.4.0

type JSONPathInfo struct {
	Path     string   // JSON path like "/tools/1" or "/age"
	Message  string   // Error message
	Location []string // Instance location from jsonschema (e.g., ["tools", "1"])
}

JSONPathInfo holds information about a validation error and its path

func ExtractJSONPathFromValidationError added in v0.4.0

func ExtractJSONPathFromValidationError(err error) []JSONPathInfo

ExtractJSONPathFromValidationError extracts JSON path information from jsonschema validation errors

type JSONPathLocation added in v0.4.0

type JSONPathLocation struct {
	Line   int
	Column int
	Found  bool
}

JSONPathLocation represents a location in YAML source corresponding to a JSON path

func LocateJSONPathInYAML added in v0.4.0

func LocateJSONPathInYAML(yamlContent string, jsonPath string) JSONPathLocation

LocateJSONPathInYAML finds the line/column position of a JSON path in YAML source

func LocateJSONPathInYAMLWithAdditionalProperties added in v0.4.0

func LocateJSONPathInYAMLWithAdditionalProperties(yamlContent string, jsonPath string, errorMessage string) JSONPathLocation

LocateJSONPathInYAMLWithAdditionalProperties finds the line/column position of a JSON path in YAML source with special handling for additional properties errors

type MCPServerConfig

type MCPServerConfig struct {
	Name           string            `json:"name"`
	Type           string            `json:"type"`           // stdio, http, docker
	Registry       string            `json:"registry"`       // URI to installation location from registry
	Command        string            `json:"command"`        // for stdio
	Args           []string          `json:"args"`           // for stdio
	Container      string            `json:"container"`      // for docker
	Version        string            `json:"version"`        // optional version/tag for container
	EntrypointArgs []string          `json:"entrypointArgs"` // arguments to add after container image
	URL            string            `json:"url"`            // for http
	Headers        map[string]string `json:"headers"`        // for http
	Env            map[string]string `json:"env"`            // environment variables
	ProxyArgs      []string          `json:"proxy-args"`     // custom proxy arguments for container-based tools
	Allowed        []string          `json:"allowed"`        // allowed tools
}

MCPServerConfig represents a parsed MCP server configuration

func ExtractMCPConfigurations

func ExtractMCPConfigurations(frontmatter map[string]any, serverFilter string) ([]MCPServerConfig, error)

ExtractMCPConfigurations extracts MCP server configurations from workflow frontmatter

func ParseMCPConfig

func ParseMCPConfig(toolName string, mcpSection any, toolConfig map[string]any) (MCPServerConfig, error)

ParseMCPConfig parses MCP configuration from various formats (map or JSON string)

type MCPServerInfo

type MCPServerInfo struct {
	Config    MCPServerConfig
	Connected bool
	Error     error
	Tools     []*mcp.Tool
	Resources []*mcp.Resource
	Roots     []*mcp.Root
}

MCPServerInfo contains the inspection results for an MCP server

type NestedSection added in v0.4.0

type NestedSection struct {
	// contains filtered or unexported fields
}

NestedSection represents a section of YAML content that corresponds to a nested object

type PathSegment added in v0.4.0

type PathSegment struct {
	Type  string // "key" or "index"
	Value string // The raw value
	Index int    // Parsed index for array elements
}

PathSegment represents a segment in a JSON path

Jump to

Keyboard shortcuts

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