parser

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpandIncludes

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

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

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, frontmatterStartLine int) (line int, column int, message string)

ExtractYAMLError extracts line and column information from YAML parsing errors

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 tool objects and returns errors for conflicts

func ProcessIncludes

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

ProcessIncludes processes @include directives in markdown content This matches the bash process_includes function behavior

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 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 MCPResourceInfo

type MCPResourceInfo struct {
	URI         string `json:"uri"`
	Name        string `json:"name"`
	Description string `json:"description"`
	MimeType    string `json:"mimeType"`
}

MCPResourceInfo represents a resource available from an MCP server

type MCPRootInfo

type MCPRootInfo struct {
	URI  string `json:"uri"`
	Name string `json:"name"`
}

MCPRootInfo represents a root available from an MCP server

type MCPServerConfig

type MCPServerConfig struct {
	Name      string            `json:"name"`
	Type      string            `json:"type"`      // stdio, http, docker
	Command   string            `json:"command"`   // for stdio
	Args      []string          `json:"args"`      // for stdio
	Container string            `json:"container"` // for docker
	URL       string            `json:"url"`       // for http
	Headers   map[string]string `json:"headers"`   // for http
	Env       map[string]string `json:"env"`       // environment variables
	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     []MCPToolInfo
	Resources []MCPResourceInfo
	Roots     []MCPRootInfo
}

MCPServerInfo contains the inspection results for an MCP server

type MCPToolInfo

type MCPToolInfo struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

MCPToolInfo represents a tool available from an MCP server

Jump to

Keyboard shortcuts

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