From b66c8dc1d12a659b06b9f7d0923ceba8eaa8d8ab Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Mon, 5 Jan 2026 05:38:17 +0900 Subject: [PATCH] feat(frontmatter): track parsing errors and frontmatter existence in result type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add hadFrontmatter and parseError flags to FrontmatterResult interface to enable error handling in skill loading. 🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode) --- src/shared/frontmatter.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/shared/frontmatter.ts b/src/shared/frontmatter.ts index 674b03d..db16420 100644 --- a/src/shared/frontmatter.ts +++ b/src/shared/frontmatter.ts @@ -3,6 +3,8 @@ import yaml from "js-yaml" export interface FrontmatterResult> { data: T body: string + hadFrontmatter: boolean + parseError: boolean } export function parseFrontmatter>( @@ -12,7 +14,7 @@ export function parseFrontmatter>( const match = content.match(frontmatterRegex) if (!match) { - return { data: {} as T, body: content } + return { data: {} as T, body: content, hadFrontmatter: false, parseError: false } } const yamlContent = match[1] @@ -22,8 +24,8 @@ export function parseFrontmatter>( // Use JSON_SCHEMA for security - prevents code execution via YAML tags const parsed = yaml.load(yamlContent, { schema: yaml.JSON_SCHEMA }) const data = (parsed ?? {}) as T - return { data, body } + return { data, body, hadFrontmatter: true, parseError: false } } catch { - return { data: {} as T, body } + return { data: {} as T, body, hadFrontmatter: true, parseError: true } } }