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
256def write_node_mirror(node: Dict[str, Any]) -> str:
257 """Write a human-readable Markdown mirror for a wiki node."""
258 relative_path = node.get("file_path") or _relative_file_path(
259 node["user_id"],
260 node["node_type"],
261 node["node_id"],
262 )
263 output_path = _wiki_root() / relative_path
264 output_path.parent.mkdir(parents=True, exist_ok=True)
265
266 metadata = node.get("metadata") or _json_loads(node.get("metadata_json"))
267 lines = [
268 "---",
269 f"node_id: {node['node_id']}",
270 f"user_id: {node['user_id']}",
271 f"node_type: {node['node_type']}",
272 f"updated_at: {node.get('updated_at') or _now()}",
273 "---",
274 "",
275 f"# {node['title']}",
276 "",
277 ]
278 keywords = str(node.get("keywords") or "").strip()
279 if keywords:
280 lines.extend([f"Keywords: {keywords}", ""])
281 if metadata:
282 lines.extend(["## Metadata", "", "```json", json.dumps(metadata, ensure_ascii=False, indent=2), "```", ""])
283 lines.extend(["## Body", "", str(node.get("body") or "").strip(), ""])
284 output_path.write_text("\n".join(lines), encoding="utf-8")
285 return relative_path
286
287
288def upsert_node(

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