One function
parse_frontmatter in wshobson/agents
The author described this change as “fix(adapters): parse nested frontmatter mappings (#618)”. It counts as a record because the check below fails on the code as it stood at d7cf7dca8 and passes on 2de74ac1c, with nothing else changed between the two runs.
Projectwshobson/agents
Fix saved2026-07-11
Sharing licenceMIT · LICENSE
Change size+16 −0
What the code was meant to do, written into the code itself as a docstring
Return (fields, body). Tolerant YAML-ish parser; no external dep. Supports: - scalar fields (`name: foo`) - inline lists (`tools: [a, b]`) and block lists (key: \n - a\n - b) - YAML block scalar indicators `>` and `|` (folded/literal multi-line strings) - 2-space continuation of scalar values
The change
| 4 | 4 | Supports: | |
| 5 | 5 | - scalar fields (`name: foo`) | |
| 6 | 6 | - inline lists (`tools: [a, b]`) and block lists (key: \\n - a\\n - b) | |
| 7 | + | - one-level mappings (`metadata: \\n version: 1.0.0`) | |
| 7 | 8 | - YAML block scalar indicators `>` and `|` (folded/literal multi-line strings) | |
| 8 | 9 | - 2-space continuation of scalar values | |
| 9 | 10 | """ | |
| ⋯ | |||
| 65 | 66 | if text: | |
| 66 | 67 | existing = fields.get(current_key) or "" | |
| 67 | 68 | fields[current_key] = (existing + " " + text).strip() if existing else text | |
| 69 | + | elif ( | |
| 70 | + | current_key | |
| 71 | + | and isinstance(fields.get(current_key), dict) | |
| 72 | + | and _is_one_level_mapping_entry(line) | |
| 73 | + | ): | |
| 74 | + | nested = re.match(r"^(\w[\w-]*):\s*(.*)", line.strip()) | |
| 75 | + | if nested: | |
| 76 | + | fields[current_key][nested.group(1)] = nested.group(2).strip().strip('"').strip("'") | |
| 68 | 77 | elif in_list and ( | |
| 69 | 78 | isinstance(fields.get(current_key), list) | |
| 70 | 79 | or (isinstance(fields.get(current_key), str) and fields[current_key] == "") | |
| ⋯ | |||
| 88 | 97 | item = stripped.strip('",[] ') | |
| 89 | 98 | if item and item != "]": | |
| 90 | 99 | fields[current_key].append(item) | |
| 100 | + | elif _is_one_level_mapping_entry(line): | |
| 101 | + | nested = re.match(r"^(\w[\w-]*):\s*(.*)", stripped) | |
| 102 | + | if nested: | |
| 103 | + | fields[current_key] = { | |
| 104 | + | nested.group(1): nested.group(2).strip().strip('"').strip("'") | |
| 105 | + | } | |
| 106 | + | in_list = False | |
| 91 | 107 | elif current_key and isinstance(fields.get(current_key), str) and line.startswith(" "): | |
| 92 | 108 | fields[current_key] += " " + line.strip().strip('"') | |
| 93 | 109 | ||
The check that tells the two apart
fail→pass·tools/tests/test_adapters.py::TestFrontmatterParser::test_nested_mapping
Check file tools/tests/test_adapters.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before itd7cf7dca8c4c7d0635e284f77204daa85552bfa4
Broken version dated2026-07-08
Moduletools.adapters.base
Units changedparse_frontmatter
Fingerprint8fb47a9f168ce29d
Checked2026-08-17 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.