Write a human-readable Markdown mirror for a wiki node.
(node: Dict[str, Any])
| 254 | ) |
| 255 | except sqlite3.OperationalError: |
| 256 | # Some embedded SQLite builds omit FTS5. LIKE fallback search still works. |
| 257 | pass |
| 258 | |
| 259 | conn.commit() |
| 260 | conn.close() |
| 261 | _wiki_root().mkdir(parents=True, exist_ok=True) |
| 262 | |
| 263 | |
| 264 | def write_node_mirror(node: Dict[str, Any]) -> str: |
| 265 | """Write a human-readable Markdown mirror for a wiki node.""" |
| 266 | relative_path = node.get("file_path") or _relative_file_path( |
| 267 | node["user_id"], |
| 268 | node["node_type"], |
| 269 | node["node_id"], |
| 270 | ) |
| 271 | output_path = _wiki_root() / relative_path |
| 272 | output_path.parent.mkdir(parents=True, exist_ok=True) |
| 273 | |
| 274 | metadata = node.get("metadata") or _json_loads(node.get("metadata_json")) |
| 275 | lines = [ |
| 276 | "---", |
| 277 | f"node_id: {node['node_id']}", |
| 278 | f"user_id: {node['user_id']}", |
| 279 | f"node_type: {node['node_type']}", |
| 280 | f"updated_at: {node.get('updated_at') or _now()}", |
| 281 | "---", |
| 282 | "", |
| 283 | f"# {node['title']}", |
| 284 | "", |
| 285 | ] |
| 286 | keywords = str(node.get("keywords") or "").strip() |
| 287 | if keywords: |
| 288 | lines.extend([f"Keywords: {keywords}", ""]) |
no test coverage detected