MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / write_node_mirror

Function write_node_mirror

skills/wiki-store/scripts/wiki_db.py:256–285  ·  view source on GitHub ↗

Write a human-readable Markdown mirror for a wiki node.

(node: Dict[str, Any])

Source from the content-addressed store, hash-verified

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
264def 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}", ""])

Callers 1

upsert_nodeFunction · 0.85

Calls 5

_relative_file_pathFunction · 0.85
_wiki_rootFunction · 0.85
_json_loadsFunction · 0.85
_nowFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected