fix: reweave regex fallback uses consistent YAML list format

The regex fallback was writing list entries as '  - "title"' (2-space
indent + quotes) while existing frontmatter uses '- title' (0-space
indent, no quotes). This caused YAML parse failures during merge.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
m3taversal 2026-04-07 01:28:10 +01:00 committed by Teleo Agents
parent a68f38609d
commit 8f6057686e

View file

@ -535,8 +535,8 @@ def _write_edge_regex(neighbor_path: Path, fm_text: str, body_text: str,
field_re = re.compile(rf"^{edge_type}:\s*$", re.MULTILINE) field_re = re.compile(rf"^{edge_type}:\s*$", re.MULTILINE)
inline_re = re.compile(rf'^{edge_type}:\s*\[', re.MULTILINE) inline_re = re.compile(rf'^{edge_type}:\s*\[', re.MULTILINE)
entry_line = f' - "{orphan_title}"' entry_line = f'- {orphan_title}'
rw_line = f' - "{orphan_title}|{edge_type}|{date_str}"' rw_line = f'- {orphan_title}|{edge_type}|{date_str}'
if field_re.search(fm_text): if field_re.search(fm_text):
# Multi-line list exists — find end of list, append # Multi-line list exists — find end of list, append
@ -548,7 +548,7 @@ def _write_edge_regex(neighbor_path: Path, fm_text: str, body_text: str,
new_lines.append(line) new_lines.append(line)
if re.match(rf"^{edge_type}:\s*$", line): if re.match(rf"^{edge_type}:\s*$", line):
in_field = True in_field = True
elif in_field and not line.startswith(" -"): elif in_field and not line.startswith(("- ", " -")):
# End of list — insert before this line # End of list — insert before this line
new_lines.insert(-1, entry_line) new_lines.insert(-1, entry_line)
in_field = False in_field = False
@ -576,7 +576,7 @@ def _write_edge_regex(neighbor_path: Path, fm_text: str, body_text: str,
new_lines.append(line) new_lines.append(line)
if re.match(r"^reweave_edges:\s*$", line): if re.match(r"^reweave_edges:\s*$", line):
in_rw = True in_rw = True
elif in_rw and not line.startswith(" -"): elif in_rw and not line.startswith(("- ", " -")):
new_lines.insert(-1, rw_line) new_lines.insert(-1, rw_line)
in_rw = False in_rw = False
inserted_rw = True inserted_rw = True