improvement: include file path in frontmatter YAML parse error messages
Summary
When a YAML syntax error occurs in a frontmatter during rulesync import, the error message does not indicate which file caused the error. This makes it difficult to identify the problematic file when importing a large number of rule files.
Steps to Reproduce
- Prepare a rule file with invalid YAML in its frontmatter (e.g., an unquoted string containing a colon such as
description: foo : bar) - Run
rulesync import --targets claudecode --global --features "*"
Current Behavior
ERROR YAMLException: incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line at line 2, column 22:
description: foo : bar
^
Expected Behavior
ERROR Failed to parse frontmatter in .rulesync/rules/example.md: YAMLException: incomplete explicit mapping pair; ...
Notes
-
The
parseFrontmatterfunction insrc/utils/frontmatter.tsaccepts an optionalfilePathsecond argument. WhenfilePathis not provided, the original error is re-thrown as-is without file information. Callers need to passfilePathto get meaningful error messages. -
Related: #1043 — PR #1052 addressed Zod validation and file-not-found errors, but parseFrontmatter YAML parse errors were not covered.
@saitota Thank you! Your point is true exactly. If you contribute this, I will be glad.