You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Markdown frontmatter parsing, import resolution, GitHub URL handling, and schema validation for agentic workflow files.
Overview
The parser package is responsible for extracting and processing YAML frontmatter from agentic workflow .md files. Frontmatter defines the workflow's entire configuration — triggers, permissions, tools, safe outputs, engine settings, network restrictions, and runtime overrides. The markdown body that follows the frontmatter serves as the AI agent's prompt text.
Beyond basic frontmatter extraction, the package provides a rich import system that resolves @import directives (local files, GitHub URLs, fragments), an include expander for @include directives in the markdown body, a schedule parser that converts natural-language schedules into cron expressions, MCP server configuration extraction, and JSON schema–backed validation with actionable error messages.
The package is designed for use both in the main CLI binary and in WebAssembly contexts (see *_wasm.go files). Build constraints separate platform-specific implementations for remote fetching and filesystem access.
Public API
Types
Type
Kind
Description
FrontmatterResult
struct
Result of extracting frontmatter from markdown content
ImportCache
struct
Thread-safe cache of resolved imports to avoid redundant fetches
ImportDirectiveMatch
struct
Parsed @import or @include directive line
ImportError
struct
Structured error for import resolution failures
ImportCycleError
struct
Structured error for circular import chains
FormattedParserError
struct
Pre-formatted parser error with display-ready message
ImportsResult
struct
Result of ProcessImportsFromFrontmatterWithSource
ImportInputDefinition
struct
Input definition from an imported workflow fragment
Reports whether value is a direct ${{ secrets.NAME }} GitHub Actions reference without additional expression operators
ParseLinearToolsets
func(value any) ([]string, error)
Validates and expands tools.linear.toolsets (a name or array of names) into the corresponding sorted, deduplicated MCP tool names; "all" expands to ["*"]
ValidateLinearAllowedForToolsets
func(allowed, toolsetTools []string) error
Checks that every tools.linear.allowed glob pattern matches at least one tool in the configured toolsets (the "*" toolset accepts any pattern)
Schedule Parsing
Function
Signature
Description
ParseSchedule
func(input string) (cron, original string, err error)
Parses natural-language or cron schedule to a cron expression
func(yamlContent string, info JSONPathInfo) JSONPathLocation
Maps a JSONPathInfo to a line/column in YAML text, handling additional-property errors
Trigger Helpers
Function
Signature
Description
IsLabelOnlyEvent
func(eventValue any) bool
Detects whether a trigger only activates on label events
IsNonConflictingCommandEvent
func(eventValue any) bool
Detects whether a trigger is a non-conflicting slash command
Inline Sub-Agent Processing
Inline sub-agents are secondary agent definitions embedded in the same markdown file as the primary workflow, delimited by ## agent: \name`level-2 headings. Each sub-agent may carry its own frontmatter block (onlydescriptionandmodel` are valid fields) plus a prompt body.
Splits markdown into the main workflow section and any inline sub-agent definitions
ValidateInlineSubAgentsFrontmatter
func(markdown string) []string
Validates inline sub-agent frontmatter in a full workflow file (strips top-level frontmatter first); returns advisory warning strings
ValidateInlineSubAgentsInBody
func(body string) []string
Validates inline sub-agent frontmatter in an already-stripped markdown body
GetEngineSubAgentExt
func(engineID string) string
Returns the file extension for sub-agent files for a given engine (.md for claude/codex/gemini, .agent.md otherwise)
Inline Skill Processing
Inline skills are secondary skill definitions embedded in the same markdown file as the primary workflow, delimited by ## skill: \name`level-2 headings. Each skill may carry its own frontmatter block (onlydescription` is a valid field) plus a content body.
The parsing pipeline for a workflow file proceeds as:
Read the raw markdown file content.
Extract the YAML frontmatter block between --- delimiters (ExtractFrontmatterFromContent).
Process imports: resolve all @import directives recursively, merge imported YAML configurations, and deduplicate (ProcessImportsFromFrontmatterWithSource).
Validate the merged frontmatter against the JSON schema (ValidateMainWorkflowFrontmatterWithSchemaAndLocation).
Expand includes in the markdown body (ExpandIncludesWithManifest).
Pass the merged frontmatter and markdown body to pkg/workflow for compilation.
Import caching is crucial for performance and cycle detection. The ImportCache tracks visited paths within a single compilation run to prevent infinite recursion.
github.com/cli/go-gh/v2 — GitHub CLI API integration for remote file fetching
github.com/modelcontextprotocol/go-sdk/mcp — MCP Go SDK for MCP server configuration
Thread Safety
ImportCache is designed for use within a single goroutine per compilation run. Its internal map is not concurrency-safe. For concurrent compilations, create a separate ImportCache per compilation.
The DefaultFileReader variable is safe to read but MUST NOT be mutated after package initialization. Tests may replace it with a custom FileReader to inject virtual filesystem content.
Source-verified export coverage
This appendix is generated from the current non-test Go source files in this package and records any exported top-level symbols that are not already described above.
Category
Count
Types
26
Constants
10
Variables
7
Functions and methods
107
Additional symbols documented in this appendix
22
Additional types
File
Symbol
Declaration
Description
mcp.go
MCPRootInfo
type MCPRootInfo struct { URI string Name string }
MCPRootInfo contains display metadata inferred from MCP server roots.
Additional constants and variables
File
Kind
Symbol
Declaration
Description
remote_resolve_sha.go
var
ErrVerificationSkipped
var ErrVerificationSkipped = errors.New("commit verification skipped")
ErrVerificationSkipped is returned when commit verification cannot be completed due to auth/permission constraints.
schedule_parser.go
var
ErrUnsupportedSyntax
var ErrUnsupportedSyntax = errors.New("unsupported schedule syntax")
ErrUnsupportedSyntax marks schedule inputs that are intentionally unsupported and should be rewritten to fuzzy or cron forms.
IsImportSafeSharedWorkflowOn validates whether an imported on: block is restricted to safe shared-workflow triggers.
Source Synchronization
Reviewed against recent source updates on 2026-07-24; no additional public-contract deltas were identified beyond the sections above. Re-verified on 2026-08-14; no public-contract changes since the last review (only internal schema-suggestions refactoring landed). Re-verified on 2026-08-29; no public-contract deltas since the last review. Re-verified on 2026-09-03; no public-contract deltas since the last review. Re-verified on 2026-09-08; added ParseLinearToolsets, ValidateLinearAllowedForToolsets, and IsSimpleSecretExpression (Linear toolset support and secret-expression validation) to the MCP Configuration public API table, which were previously undocumented. Re-verified on 2026-09-13; no public-contract deltas since the last review. Re-verified on 2026-09-23; added the previously undocumented ValidationError type and NewValidationError constructor to the Public API section, added the three exported Error() string methods (*ImportCycleError, *FormattedParserError, *ValidationError) to the export-coverage appendix, and removed duplicate appendix rows for ParseLinearToolsets/ValidateLinearAllowedForToolsets/IsSimpleSecretExpression that were already documented above; corrected the export-coverage summary counts to match current source (26 types, 107 functions/methods, 22 additional appendix symbols). Re-verified on 2026-09-28; no public-contract deltas since the last review.
This specification is automatically maintained by the spec-extractor workflow.