"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
fix(agent): accept a UTF-8 byte-order mark before frontmatter
Haozhe Wu8ba590eade6d
diff --git a/agent/src/agent/frontmatter.py b/agent/src/agent/frontmatter.pyindex e302eeb5f..bb06abf8b 100644--- a/agent/src/agent/frontmatter.py+++ b/agent/src/agent/frontmatter.py@@ -16,7 +16,8 @@ _FRONTMATTER_RE = re.compile(def parse_frontmatter(text: str) -> tuple[Dict[str, Any], str]:"""Parse YAML-like frontmatter and body from a markdown file.- Supports string, quoted string, list (``[a, b]``), and boolean values.+ Supports string, quoted string, list (``[a, b]``), and boolean values;+ a leading UTF-8 byte-order mark is ignored.Args:text: Markdown text with optional ``---`` delimited frontmatter.@@ -24,7 +25,7 @@ def parse_frontmatter(text: str) -> tuple[Dict[str, Any], str]:Returns:Tuple of (metadata dict, body text)."""- match = _FRONTMATTER_RE.match(text)+ match = _FRONTMATTER_RE.match(text.removeprefix("\ufeff"))if not match:return {}, text.strip()diff --git a/agent/tests/test_skills.py b/agent/tests/test_skills.pyindex f88b5b7b8..28c8eac91 100644--- a/agent/tests/test_skills.py+++ b/agent/tests/test_skills.py@@ -48,6 +48,12 @@ class TestParseFrontmatter:meta, _ = _parse_frontmatter(text)assert meta == {"name": "foo", "description": "Use when: a, b", "flag": "true", "raw": "[a]"}+ def test_utf8_bom_before_frontmatter(self) -> None:+ text = "\ufeff---\nname: momentum-x\ndescription: My rules\n---\nBody"+ meta, body = _parse_frontmatter(text)+ assert meta == {"name": "momentum-x", "description": "My rules"}+ assert body == "Body"+def test_no_frontmatter(self) -> None:text = "Just plain text, no frontmatter."meta, body = _parse_frontmatter(text)