@@ -154,7 +154,9 @@ def _package_relative(path: str) -> str:
154154 return path
155155
156156
157- def _read_leading_frontmatter (md_path : Path , * , kind : str , name : str ) -> dict [str , Any ]:
157+ def _read_leading_frontmatter (
158+ md_path : Path , * , kind : str , name : str , source_path : str
159+ ) -> dict [str , Any ]:
158160 """Parse the ``---``-fenced YAML block at the head of ``md_path``.
159161
160162 Returns ``{}`` if the file has no frontmatter block. Raises
@@ -166,10 +168,10 @@ def _read_leading_frontmatter(md_path: Path, *, kind: str, name: str) -> dict[st
166168 except OSError as exc :
167169 raise CoreInventoryError (
168170 error = "core_inventory.read_failed" ,
169- message = f"Could not read { kind } file: { exc } " ,
171+ message = f"Could not read { kind } file: { exc . strerror or exc } " ,
170172 kind = kind ,
171173 name = name ,
172- source_path = str ( md_path ) ,
174+ source_path = source_path ,
173175 ) from exc
174176
175177 if not text .startswith ("---" ):
@@ -190,7 +192,7 @@ def _read_leading_frontmatter(md_path: Path, *, kind: str, name: str) -> dict[st
190192 ),
191193 kind = kind ,
192194 name = name ,
193- source_path = str ( md_path ) ,
195+ source_path = source_path ,
194196 )
195197
196198 import yaml # lazy import per constitution IV
@@ -206,7 +208,7 @@ def _read_leading_frontmatter(md_path: Path, *, kind: str, name: str) -> dict[st
206208 ),
207209 kind = kind ,
208210 name = name ,
209- source_path = str ( md_path ) ,
211+ source_path = source_path ,
210212 ) from exc
211213
212214 if parsed is None :
@@ -220,7 +222,7 @@ def _read_leading_frontmatter(md_path: Path, *, kind: str, name: str) -> dict[st
220222 ),
221223 kind = kind ,
222224 name = name ,
223- source_path = str ( md_path ) ,
225+ source_path = source_path ,
224226 )
225227 return parsed
226228
@@ -293,7 +295,9 @@ def _build_command_entry(name: str, layout: _CoreLayout) -> dict[str, Any]:
293295 name = name ,
294296 source_path = source_path ,
295297 )
296- frontmatter = _read_leading_frontmatter (file_path , kind = "command" , name = name )
298+ frontmatter = _read_leading_frontmatter (
299+ file_path , kind = "command" , name = name , source_path = source_path
300+ )
297301 description = _normalize_description (
298302 frontmatter .get ("description" ),
299303 kind = "command" ,
@@ -345,7 +349,9 @@ def _extract_template_description(md_path: Path, *, name: str, source_path: str)
345349 ``# `` H1 heading. Raises :class:`CoreInventoryError` if neither yields
346350 a non-empty string.
347351 """
348- frontmatter = _read_leading_frontmatter (md_path , kind = "template" , name = name )
352+ frontmatter = _read_leading_frontmatter (
353+ md_path , kind = "template" , name = name , source_path = source_path
354+ )
349355 fm_desc = frontmatter .get ("description" )
350356 if isinstance (fm_desc , str ):
351357 candidate = fm_desc .strip ()
0 commit comments