XMind 思维导图处理技能 此技能提供 XMind 文件( )的完整处理能力:解析、创建和更新。通过配套的 Python 工具脚本实现文件操作,将思维导图内容转换为 Markdown 格式作为会话级记忆,便于用户与模型持续交流和编辑。 工具脚本 本技能依赖 (相对于本技能目录),使用 Python 标准库(零第三方依赖)。执行方式: 会话管理 所有命令都需要 参数,用于隔离不同会话的记忆文件。 会话 ID 获取规则(按优先级): 1. 从上下文中获取:如果当前对话上下文中已存在之前使用过的 session ID,直接复用 2. 生成新 ID:如果上下文中没有可用的 session ID,在首次调用前生成一个 UUID v4 格式的字符串(例如 ),并在后续调用中持续复用 - 记忆文件存储路径: 支持的格式 | 格式 | 版本 | 内部结构 | 检测方式 | |------|------|---------|---------| | Zen | XMind Zen / 2020+ | ZIP 内含 | 自动检测 | | Legacy | XMind 8 | ZIP 内含 | 自动检测 | 创建新文件时默认使用 Zen 格式;更新已有文件时保留原格式。 Markdown 表示规范 解析后的 Markdown 使用缩进列表式结构,格式如下: 格式说明: - — 工作表标题(多工作表之…

, line)\n if not m:\n idx += 1\n continue\n\n cur_indent = len(m.group(1))\n topic = _parse_title_meta(m.group(2))\n\n idx += 1\n child_lines = []\n note_lines = []\n\n while idx \u003c len(lines):\n nxt = lines[idx]\n stripped = nxt.strip()\n\n if not stripped:\n idx += 1\n continue\n\n # 是否是列表项?\n nm = re.match(r'^(\\s*)- ', nxt)\n if nm:\n nxt_indent = len(nm.group(1))\n if nxt_indent > cur_indent:\n child_lines.append(nxt)\n idx += 1\n continue\n else:\n break\n\n # 是否是备注行(blockquote)?\n bm = re.match(r'^(\\s*)> (.*)

XMind 思维导图处理技能 此技能提供 XMind 文件( )的完整处理能力:解析、创建和更新。通过配套的 Python 工具脚本实现文件操作,将思维导图内容转换为 Markdown 格式作为会话级记忆,便于用户与模型持续交流和编辑。 工具脚本 本技能依赖 (相对于本技能目录),使用 Python 标准库(零第三方依赖)。执行方式: 会话管理 所有命令都需要 参数,用于隔离不同会话的记忆文件。 会话 ID 获取规则(按优先级): 1. 从上下文中获取:如果当前对话上下文中已存在之前使用过的 session ID,直接复用 2. 生成新 ID:如果上下文中没有可用的 session ID,在首次调用前生成一个 UUID v4 格式的字符串(例如 ),并在后续调用中持续复用 - 记忆文件存储路径: 支持的格式 | 格式 | 版本 | 内部结构 | 检测方式 | |------|------|---------|---------| | Zen | XMind Zen / 2020+ | ZIP 内含 | 自动检测 | | Legacy | XMind 8 | ZIP 内含 | 自动检测 | 创建新文件时默认使用 Zen 格式;更新已有文件时保留原格式。 Markdown 表示规范 解析后的 Markdown 使用缩进列表式结构,格式如下: 格式说明: - — 工作表标题(多工作表之…

, nxt)\n if bm:\n bm_indent = len(bm.group(1))\n # 当前节点的备注:缩进恰好为 cur_indent+2,且尚未出现子节点\n if not child_lines and bm_indent == cur_indent + 2:\n note_lines.append(bm.group(2))\n idx += 1\n continue\n # 属于子节点的备注或内容\n elif bm_indent > cur_indent:\n child_lines.append(nxt)\n idx += 1\n continue\n else:\n break\n\n # 可能是子层级的续行\n if nxt.startswith(' ' * (cur_indent + 2)):\n child_lines.append(nxt)\n idx += 1\n continue\n\n break\n\n if note_lines:\n topic.notes = '\\n'.join(note_lines)\n if child_lines:\n topic.children = _parse_md_items(child_lines)\n\n items.append(topic)\n\n return items\n\n\ndef _parse_title_meta(raw):\n \"\"\"从标题行解析行内元数据 {labels:...} {link:...} {markers:...}。\"\"\"\n topic = Topic()\n remaining = raw\n\n for key, attr in [('labels', 'labels'), ('link', 'link'), ('markers', 'markers')]:\n pattern = r'\\{' + key + r':\\s*([^}]+)\\}'\n match = re.search(pattern, remaining)\n if match:\n val = match.group(1).strip()\n if key in ('labels', 'markers'):\n setattr(topic, attr, [v.strip() for v in val.split(',') if v.strip()])\n else:\n setattr(topic, attr, val)\n remaining = remaining[:match.start()] + remaining[match.end():]\n\n topic.title = remaining.strip()\n return topic\n\n\ndef _apply_block_meta(topic, meta_lines):\n \"\"\"从 blockquote 行中提取元数据并应用到节点。\"\"\"\n note_parts = []\n for line in meta_lines:\n text = re.sub(r'^>\\s*', '', line)\n if text.startswith('Labels:'):\n topic.labels = [v.strip() for v in text[7:].split(',') if v.strip()]\n elif text.startswith('Link:'):\n topic.link = text[5:].strip()\n elif text.startswith('Markers:'):\n topic.markers = [v.strip() for v in text[8:].split(',') if v.strip()]\n else:\n note_parts.append(text)\n if note_parts:\n topic.notes = '\\n'.join(note_parts)\n\n\n# ============================================================\n# 创建 XMind — Zen 格式\n# ============================================================\n\ndef create_zen(sheets, output_path):\n \"\"\"以 Zen 格式创建 .xmind 文件。\"\"\"\n content = []\n for sheet in sheets:\n sheet_data = {\n 'id': sheet.id,\n 'class': 'sheet',\n 'title': sheet.title,\n }\n if sheet.root_topic:\n sheet_data['rootTopic'] = _topic_to_zen_dict(sheet.root_topic)\n content.append(sheet_data)\n\n metadata = {\n 'creator': {\n 'name': 'xmind-tool',\n 'version': '1.0.0',\n }\n }\n\n with zipfile.ZipFile(output_path, 'w', zipfile.ZIP_DEFLATED) as zf:\n zf.writestr('content.json', json.dumps(content, ensure_ascii=False, indent=2))\n zf.writestr('metadata.json', json.dumps(metadata, ensure_ascii=False, indent=2))\n\n return output_path\n\n\ndef _topic_to_zen_dict(topic):\n data = {\n 'id': topic.id,\n 'class': 'topic',\n 'title': topic.title,\n }\n if topic.notes:\n data['notes'] = {'plain': {'content': topic.notes}}\n if topic.labels:\n data['labels'] = topic.labels\n if topic.link:\n data['href'] = topic.link\n if topic.markers:\n data['markers'] = [{'markerId': m} for m in topic.markers]\n if topic.children:\n data['children'] = {\n 'attached': [_topic_to_zen_dict(c) for c in topic.children]\n }\n return data\n\n\n# ============================================================\n# 创建 XMind — Legacy 格式 (XMind 8)\n# ============================================================\n\n_CONTENT_NS = 'urn:xmind:xmap:xmlns:content:2.0'\n_XLINK_NS = 'http://www.w3.org/1999/xlink'\n\n\ndef _ctag(local):\n \"\"\"为 Legacy XML 元素添加内容命名空间前缀。\"\"\"\n return f'{{{_CONTENT_NS}}}{local}'\n\n\ndef create_legacy(sheets, output_path):\n \"\"\"以 Legacy (XMind 8) 格式创建 .xmind 文件。\"\"\"\n ET.register_namespace('', _CONTENT_NS)\n ET.register_namespace('xlink', _XLINK_NS)\n\n root = ET.Element(_ctag('xmap-content'))\n root.set('version', '2.0')\n\n for sheet in sheets:\n sheet_elem = ET.SubElement(root, _ctag('sheet'))\n sheet_elem.set('id', sheet.id)\n sheet_elem.set('timestamp', str(int(time.time() * 1000)))\n\n if sheet.root_topic:\n _topic_to_legacy_xml(sheet_elem, sheet.root_topic)\n\n title_elem = ET.SubElement(sheet_elem, _ctag('title'))\n title_elem.text = sheet.title\n\n tree = ET.ElementTree(root)\n\n manifest = (\n '\u003c?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\\n'\n '\u003cmanifest xmlns=\"urn:xmind:xmap:xmlns:manifest:1.0\">\\n'\n ' \u003cfile-entry full-path=\"content.xml\" media-type=\"text/xml\"/>\\n'\n ' \u003cfile-entry full-path=\"META-INF/\" media-type=\"\"/>\\n'\n ' \u003cfile-entry full-path=\"META-INF/manifest.xml\" media-type=\"text/xml\"/>\\n'\n '\u003c/manifest>'\n )\n\n with zipfile.ZipFile(output_path, 'w', zipfile.ZIP_DEFLATED) as zf:\n buf = io.BytesIO()\n tree.write(buf, encoding='UTF-8', xml_declaration=True)\n zf.writestr('content.xml', buf.getvalue())\n zf.writestr('META-INF/manifest.xml', manifest)\n\n return output_path\n\n\ndef _topic_to_legacy_xml(parent, topic):\n elem = ET.SubElement(parent, _ctag('topic'))\n elem.set('id', topic.id)\n elem.set('timestamp', str(int(time.time() * 1000)))\n\n t = ET.SubElement(elem, _ctag('title'))\n t.text = topic.title\n\n if topic.notes:\n notes_e = ET.SubElement(elem, _ctag('notes'))\n plain_e = ET.SubElement(notes_e, _ctag('plain'))\n plain_e.text = topic.notes\n\n if topic.labels:\n labels_e = ET.SubElement(elem, _ctag('labels'))\n for lbl in topic.labels:\n le = ET.SubElement(labels_e, _ctag('label'))\n le.text = lbl\n\n if topic.link:\n elem.set(f'{{{_XLINK_NS}}}href', topic.link)\n\n if topic.markers:\n mrefs = ET.SubElement(elem, _ctag('marker-refs'))\n for mid in topic.markers:\n mr = ET.SubElement(mrefs, _ctag('marker-ref'))\n mr.set('marker-id', mid)\n\n if topic.children:\n children_e = ET.SubElement(elem, _ctag('children'))\n topics_e = ET.SubElement(children_e, _ctag('topics'))\n topics_e.set('type', 'attached')\n for child in topic.children:\n _topic_to_legacy_xml(topics_e, child)\n\n\n# ============================================================\n# 更新\n# ============================================================\n\ndef update_xmind(xmind_path, md_path):\n \"\"\"从修改后的 Markdown 更新已有 XMind 文件(保留原格式)。\"\"\"\n fmt = detect_format(xmind_path)\n\n with open(md_path, 'r', encoding='utf-8') as f:\n md_text = f.read()\n\n sheets = markdown_to_sheets(md_text)\n\n if fmt == 'zen':\n create_zen(sheets, xmind_path)\n else:\n create_legacy(sheets, xmind_path)\n\n return xmind_path\n\n\n# ============================================================\n# 会话记忆文件管理\n# ============================================================\n\ndef get_memory_dir(session_id):\n \"\"\"获取会话记忆目录: /tmp/skills-xmind-parsed/\u003csession-id>/\"\"\"\n d = os.path.join(tempfile.gettempdir(), 'skills-xmind-parsed', session_id)\n os.makedirs(d, exist_ok=True)\n return d\n\n\ndef get_memory_path(session_id, xmind_path):\n \"\"\"根据 session ID 和 xmind 文件路径生成对应的记忆文件路径。\"\"\"\n stem = Path(xmind_path).stem\n return os.path.join(get_memory_dir(session_id), f'{stem}.md')\n\n\n# ============================================================\n# CLI 入口\n# ============================================================\n\ndef cmd_parse(session_id, args):\n if not args:\n print('错误:缺少 xmind 文件路径', file=sys.stderr)\n return 1\n\n xmind_path = args[0]\n if not os.path.exists(xmind_path):\n print(f'错误:文件不存在: {xmind_path}', file=sys.stderr)\n return 1\n\n fmt = detect_format(xmind_path)\n sheets = parse_zen(xmind_path) if fmt == 'zen' else parse_legacy(xmind_path)\n md = sheets_to_markdown(sheets)\n\n # 保存到会话记忆\n mem = get_memory_path(session_id, xmind_path)\n with open(mem, 'w', encoding='utf-8') as f:\n f.write(md)\n\n print(md)\n print(f'\\n\u003c!-- memory_file: {mem} -->')\n return 0\n\n\ndef cmd_create(session_id, args):\n if len(args) \u003c 2:\n print('用法: xmind_tool.py --session \u003cid> create \u003coutput.xmind> \u003cinput.md> [--format zen|legacy]', file=sys.stderr)\n return 1\n\n output_path = args[0]\n md_path = args[1]\n\n fmt = 'zen'\n if '--format' in args:\n fi = args.index('--format')\n if fi + 1 \u003c len(args):\n fmt = args[fi + 1]\n\n if not os.path.exists(md_path):\n print(f'错误:Markdown 文件不存在: {md_path}', file=sys.stderr)\n return 1\n\n with open(md_path, 'r', encoding='utf-8') as f:\n md_text = f.read()\n\n sheets = markdown_to_sheets(md_text)\n if not sheets:\n print('错误:未能从 Markdown 中解析出任何工作表', file=sys.stderr)\n return 1\n\n if fmt == 'legacy':\n create_legacy(sheets, output_path)\n else:\n create_zen(sheets, output_path)\n\n # 更新会话记忆\n mem = get_memory_path(session_id, output_path)\n with open(mem, 'w', encoding='utf-8') as f:\n f.write(md_text)\n\n print(f'已创建: {output_path}')\n print(f'格式: {fmt}')\n print(f'记忆文件: {mem}')\n return 0\n\n\ndef cmd_update(session_id, args):\n if len(args) \u003c 2:\n print('用法: xmind_tool.py --session \u003cid> update \u003cfile.xmind> \u003cmodified.md>', file=sys.stderr)\n return 1\n\n xmind_path = args[0]\n md_path = args[1]\n\n if not os.path.exists(xmind_path):\n print(f'错误:XMind 文件不存在: {xmind_path}', file=sys.stderr)\n return 1\n if not os.path.exists(md_path):\n print(f'错误:Markdown 文件不存在: {md_path}', file=sys.stderr)\n return 1\n\n update_xmind(xmind_path, md_path)\n\n # 更新会话记忆\n mem = get_memory_path(session_id, xmind_path)\n with open(md_path, 'r', encoding='utf-8') as f:\n md_text = f.read()\n with open(mem, 'w', encoding='utf-8') as f:\n f.write(md_text)\n\n print(f'已更新: {xmind_path}')\n print(f'记忆文件: {mem}')\n return 0\n\n\ndef cmd_memory(session_id, args):\n if not args:\n print('错误:缺少 xmind 文件路径', file=sys.stderr)\n return 1\n\n xmind_path = args[0]\n mem = get_memory_path(session_id, xmind_path)\n\n if os.path.exists(mem):\n with open(mem, 'r', encoding='utf-8') as f:\n print(f.read())\n else:\n print(f'未找到记忆文件: {mem}', file=sys.stderr)\n print(f'请先使用 parse 命令解析对应的 xmind 文件。', file=sys.stderr)\n return 1\n return 0\n\n\ndef print_usage():\n print(__doc__.strip())\n\n\ndef main():\n argv = sys.argv[1:]\n\n if not argv or argv[0] in ('-h', '--help', 'help'):\n print_usage()\n sys.exit(0 if argv else 1)\n\n # 解析 --session 参数\n session_id = None\n if '--session' in argv:\n si = argv.index('--session')\n if si + 1 \u003c len(argv):\n session_id = argv[si + 1]\n argv = argv[:si] + argv[si + 2:]\n else:\n print('错误:--session 需要提供会话 ID', file=sys.stderr)\n sys.exit(1)\n\n if not session_id:\n print('错误:缺少必填参数 --session \u003cid>', file=sys.stderr)\n print_usage()\n sys.exit(1)\n\n if not argv:\n print_usage()\n sys.exit(1)\n\n cmd = argv[0]\n rest = argv[1:]\n\n dispatch = {\n 'parse': cmd_parse,\n 'create': cmd_create,\n 'update': cmd_update,\n 'memory': cmd_memory,\n }\n\n fn = dispatch.get(cmd)\n if fn is None:\n print(f'未知命令: {cmd}', file=sys.stderr)\n print_usage()\n sys.exit(1)\n\n sys.exit(fn(session_id, rest))\n\n\nif __name__ == '__main__':\n main()\n","content_type":"text/x-python; charset=utf-8","language":"python","size":24033,"content_sha256":"995a437cb055312971ec5a1e98c27cd357c03ef0534ee4a7f0185b0cc781ee94"}],"content_json":{"type":"doc","content":[{"type":"heading","attrs":{"level":1},"content":[{"text":"XMind 思维导图处理技能","type":"text"}]},{"type":"paragraph","content":[{"text":"此技能提供 XMind 文件(","type":"text"},{"text":".xmind","type":"text","marks":[{"type":"code_inline"}]},{"text":")的完整处理能力:解析、创建和更新。通过配套的 Python 工具脚本实现文件操作,将思维导图内容转换为 Markdown 格式作为会话级记忆,便于用户与模型持续交流和编辑。","type":"text"}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"工具脚本","type":"text"}]},{"type":"paragraph","content":[{"text":"本技能依赖 ","type":"text"},{"text":"scripts/xmind_tool.py","type":"text","marks":[{"type":"code_inline"}]},{"text":"(相对于本技能目录),使用 Python 标准库(零第三方依赖)。执行方式:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"python skills/xmind/scripts/xmind_tool.py --session \u003csession-id> \u003ccommand> [args...]","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"会话管理","type":"text"}]},{"type":"paragraph","content":[{"text":"所有命令都需要 ","type":"text"},{"text":"--session \u003cid>","type":"text","marks":[{"type":"code_inline"}]},{"text":" 参数,用于隔离不同会话的记忆文件。","type":"text"}]},{"type":"paragraph","content":[{"text":"会话 ID 获取规则(按优先级):","type":"text","marks":[{"type":"strong"}]}]},{"type":"ordered_list","attrs":{"order":1,"listStyle":"number"},"content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"从上下文中获取:如果当前对话上下文中已存在之前使用过的 session ID,直接复用","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"生成新 ID:如果上下文中没有可用的 session ID,在首次调用前生成一个 UUID v4 格式的字符串(例如 ","type":"text"},{"text":"f47ac10b-58cc-4372-a567-0e02b2c3d479","type":"text","marks":[{"type":"code_inline"}]},{"text":"),并在后续调用中持续复用","type":"text"}]}]}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"记忆文件存储路径:","type":"text"},{"text":"/tmp/skills-xmind-parsed/\u003csession-id>/\u003cfilename>.md","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"支持的格式","type":"text"}]},{"type":"table","attrs":{"layout":null},"content":[{"type":"tr","content":[{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"格式","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"版本","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"内部结构","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"检测方式","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Zen","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"XMind Zen / 2020+","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"ZIP 内含 ","type":"text"},{"text":"content.json","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"自动检测","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Legacy","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"XMind 8","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"ZIP 内含 ","type":"text"},{"text":"content.xml","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"自动检测","type":"text"}]}]}]}]},{"type":"paragraph","content":[{"text":"创建新文件时默认使用 Zen 格式;更新已有文件时保留原格式。","type":"text"}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Markdown 表示规范","type":"text"}]},{"type":"paragraph","content":[{"text":"解析后的 Markdown 使用缩进列表式结构,格式如下:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"markdown"},"content":[{"text":"# Sheet: 工作表标题\n\n## 中心主题\n\n> Labels: 标签1, 标签2\n> Link: https://example.com\n> Markers: priority-1\n> 这里是中心主题的备注内容\n\n- 分支1 {labels: 重要} {link: https://example.com}\n > 这是分支1的备注\n > 备注可以有多行\n - 子节点1.1 {markers: task-done, priority-1}\n - 子子节点1.1.1\n - 子节点1.2\n- 分支2\n - 子节点2.1\n - 子节点2.2","type":"text"}]},{"type":"paragraph","content":[{"text":"格式说明:","type":"text","marks":[{"type":"strong"}]}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"# Sheet: 标题","type":"text","marks":[{"type":"code_inline"}]},{"text":" — 工作表标题(多工作表之间用 ","type":"text"},{"text":"---","type":"text","marks":[{"type":"code_inline"}]},{"text":" 分隔)","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"## 标题","type":"text","marks":[{"type":"code_inline"}]},{"text":" — 中心主题","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"- 内容","type":"text","marks":[{"type":"code_inline"}]},{"text":" — 节点,使用 2 空格缩进表示层级","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"{labels: ...}","type":"text","marks":[{"type":"code_inline"}]},{"text":" — 行内标签元数据","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"{link: ...}","type":"text","marks":[{"type":"code_inline"}]},{"text":" — 行内超链接元数据","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"{markers: ...}","type":"text","marks":[{"type":"code_inline"}]},{"text":" — 行内标记/图标元数据","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"> 内容","type":"text","marks":[{"type":"code_inline"}]},{"text":" — 节点备注(blockquote 形式,紧跟在节点下方)","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"中心主题的元数据使用顶层 blockquote(","type":"text"},{"text":"> Labels:","type":"text","marks":[{"type":"code_inline"}]},{"text":", ","type":"text"},{"text":"> Link:","type":"text","marks":[{"type":"code_inline"}]},{"text":", ","type":"text"},{"text":"> Markers:","type":"text","marks":[{"type":"code_inline"}]},{"text":")","type":"text"}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"核心流程","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"场景一:解析 XMind 文件","type":"text"}]},{"type":"paragraph","content":[{"text":"触发词","type":"text","marks":[{"type":"strong"}]},{"text":":\"解析 xmind\"、\"打开思维导图\"、\"查看 xmind 内容\"、\"xmind 转 markdown\"","type":"text"}]},{"type":"paragraph","content":[{"text":"步骤:","type":"text","marks":[{"type":"strong"}]}]},{"type":"ordered_list","attrs":{"order":1,"listStyle":"number"},"content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"确认文件路径","type":"text","marks":[{"type":"strong"}]},{"text":":确认用户提供的 ","type":"text"},{"text":".xmind","type":"text","marks":[{"type":"code_inline"}]},{"text":" 文件路径是否存在","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"执行解析","type":"text","marks":[{"type":"strong"}]},{"text":":运行工具脚本","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"python skills/xmind/scripts/xmind_tool.py --session \u003csession-id> parse \u003cfile.xmind>","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"展示结果","type":"text","marks":[{"type":"strong"}]},{"text":":将输出的 Markdown 内容展示给用户,包括:","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"思维导图的整体结构概览","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"各节点的层级关系","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"附带的标签、备注、链接等元数据","type":"text"}]}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"记录记忆路径","type":"text","marks":[{"type":"strong"}]},{"text":":输出末尾的 ","type":"text"},{"text":"\u003c!-- memory_file: ... -->","type":"text","marks":[{"type":"code_inline"}]},{"text":" 注释包含记忆文件路径,记住该路径以便后续操作使用","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"引导交互","type":"text","marks":[{"type":"strong"}]},{"text":":提示用户可以继续对思维导图内容进行提问、修改或导出","type":"text"}]}]}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"场景二:创建 XMind 文件","type":"text"}]},{"type":"paragraph","content":[{"text":"触发词","type":"text","marks":[{"type":"strong"}]},{"text":":\"创建 xmind\"、\"新建思维导图\"、\"生成 xmind\"","type":"text"}]},{"type":"paragraph","content":[{"text":"步骤:","type":"text","marks":[{"type":"strong"}]}]},{"type":"ordered_list","attrs":{"order":1,"listStyle":"number"},"content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"收集需求","type":"text","marks":[{"type":"strong"}]},{"text":":与用户交流,明确思维导图的结构:","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"中心主题是什么?","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"有哪些主要分支?","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"各分支下有哪些子节点?","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"是否需要添加标签、备注、链接等?","type":"text"}]}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"生成 Markdown","type":"text","marks":[{"type":"strong"}]},{"text":":根据用户描述,按照上述 Markdown 规范生成内容","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"写入临时 Markdown 文件并执行创建","type":"text","marks":[{"type":"strong"}]},{"text":":","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"# 将 markdown 内容写入临时文件,然后执行创建\npython skills/xmind/scripts/xmind_tool.py --session \u003csession-id> create \u003coutput.xmind> \u003ctemp.md> [--format zen|legacy]","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"确认创建结果","type":"text","marks":[{"type":"strong"}]},{"text":":向用户报告文件创建成功,展示文件路径","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"保持记忆","type":"text","marks":[{"type":"strong"}]},{"text":":记忆文件已自动创建,后续可继续编辑","type":"text"}]}]}]},{"type":"paragraph","content":[{"text":"格式选择:","type":"text","marks":[{"type":"strong"}]}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"默认创建 Zen 格式(现代格式,兼容性更好)","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"如果用户明确要求 XMind 8 兼容格式,使用 ","type":"text"},{"text":"--format legacy","type":"text","marks":[{"type":"code_inline"}]},{"text":" 参数","type":"text"}]}]}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"场景三:更新 XMind 文件","type":"text"}]},{"type":"paragraph","content":[{"text":"触发词","type":"text","marks":[{"type":"strong"}]},{"text":":\"更新 xmind\"、\"修改思维导图\"、\"编辑 xmind\"","type":"text"}]},{"type":"paragraph","content":[{"text":"步骤:","type":"text","marks":[{"type":"strong"}]}]},{"type":"ordered_list","attrs":{"order":1,"listStyle":"number"},"content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"加载当前内容","type":"text","marks":[{"type":"strong"}]},{"text":":","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"首先尝试读取记忆文件(如果之前已解析过):","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"python skills/xmind/scripts/xmind_tool.py --session \u003csession-id> memory \u003cfile.xmind>","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"如果没有记忆文件,先执行解析:","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"python skills/xmind/scripts/xmind_tool.py --session \u003csession-id> parse \u003cfile.xmind>","type":"text"}]}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"理解修改需求","type":"text","marks":[{"type":"strong"}]},{"text":":与用户确认要进行的修改,例如:","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"添加新分支或子节点","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"删除某个节点","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"修改节点内容、标签或备注","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"调整节点层级关系","type":"text"}]}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"修改 Markdown","type":"text","marks":[{"type":"strong"}]},{"text":":在记忆文件的基础上进行修改,确保格式符合规范","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"写入修改后的 Markdown","type":"text","marks":[{"type":"strong"}]},{"text":":将修改后的内容写入临时文件","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"执行更新","type":"text","marks":[{"type":"strong"}]},{"text":":","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"python skills/xmind/scripts/xmind_tool.py --session \u003csession-id> update \u003cfile.xmind> \u003cmodified.md>","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"确认结果","type":"text","marks":[{"type":"strong"}]},{"text":":向用户报告更新成功,展示变更摘要","type":"text"}]}]}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"场景四:基于记忆继续交流","type":"text"}]},{"type":"paragraph","content":[{"text":"当用户在同一会话中再次提到已解析的 xmind 文件时:","type":"text"}]},{"type":"ordered_list","attrs":{"order":1,"listStyle":"number"},"content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"读取记忆文件","type":"text","marks":[{"type":"strong"}]},{"text":":使用 ","type":"text"},{"text":"memory","type":"text","marks":[{"type":"code_inline"}]},{"text":" 命令获取之前解析的内容","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"基于内容回答","type":"text","marks":[{"type":"strong"}]},{"text":":根据 Markdown 内容回答用户问题","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"支持操作","type":"text","marks":[{"type":"strong"}]},{"text":":","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"总结思维导图要点","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"搜索特定节点","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"分析结构和层级关系","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"提出改进建议","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"将内容转换为其他格式(大纲、表格等)","type":"text"}]}]}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"注意事项","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"解析和创建操作涉及文件 I/O,执行前确认路径有效","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"更新操作会覆盖原文件,如用户未明确要求,建议先备份或另存为新文件","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"记忆文件存储在 ","type":"text"},{"text":"/tmp/skills-xmind-parsed/\u003csession-id>/","type":"text","marks":[{"type":"code_inline"}]},{"text":",会话结束后可能被系统清理","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"如遇到损坏的 xmind 文件(非有效 ZIP 或缺少关键内容文件),向用户报告具体错误","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"XMind 文件中的图片附件不会包含在 Markdown 中,仅处理文本结构和元数据","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"整个流程中使用中文与用户交互","type":"text"}]}]}]}]},"metadata":{"date":"2026-11-02","name":"xmind","author":"@skillopedia","source":{"stars":3,"repo_name":"skills","origin_url":"https://github.com/Mitscherlich/skills/blob/HEAD/skills/xmind/SKILL.md","repo_owner":"Mitscherlich","body_sha256":"21936fdd9e5329cb08912bc7666ecbc49c424901815fa37aeb48e412dc490a31","cluster_key":"6793629f37e53cdc7d11428d961794416d74c11f2fd98b8054baa9de4cad2497","clean_bundle":{"format":"clean-skill-bundle-v1","source":"Mitscherlich/skills/skills/xmind/SKILL.md","text_bytes":24033,"source_commit":"3c0868becaa67adfdcc7021a388cadc4e563c2f1","skills_sh_rank":13447,"attachment_count":1,"text_attachments":1,"attachment_storage":"skill_attachments","binary_attachments":0},"cluster_size":1,"skill_md_path":"skills/xmind/SKILL.md","import_metadata":{"date":"2026-11-02","author":"@skillopedia","version":"0.2.0","category":"productivity-workflow","category_label":"Productivity"},"exact_dupes_collapsed_into_this":0},"version":"0.2.0","category":"productivity-workflow","import_tag":"skills-sh-top20k-2026-11","description":"当用户要求\"解析 xmind\"、\"打开思维导图\"、\"创建 xmind\"、\"新建思维导图\"、\"更新 xmind\"、\"修改思维导图\"、\"xmind 转 markdown\"、\"查看 xmind 内容\"时,应使用此技能。此技能提供 XMind 思维导图文件的解析、创建和更新能力,支持 XMind 8 和 XMind Zen/2020+ 两种格式,并将内容转换为 Markdown 作为会话记忆,方便持续交流。"}},"renderedAt":1793671412392}

XMind 思维导图处理技能 此技能提供 XMind 文件( )的完整处理能力:解析、创建和更新。通过配套的 Python 工具脚本实现文件操作,将思维导图内容转换为 Markdown 格式作为会话级记忆,便于用户与模型持续交流和编辑。 工具脚本 本技能依赖 (相对于本技能目录),使用 Python 标准库(零第三方依赖)。执行方式: 会话管理 所有命令都需要 参数,用于隔离不同会话的记忆文件。 会话 ID 获取规则(按优先级): 1. 从上下文中获取:如果当前对话上下文中已存在之前使用过的 session ID,直接复用 2. 生成新 ID:如果上下文中没有可用的 session ID,在首次调用前生成一个 UUID v4 格式的字符串(例如 ),并在后续调用中持续复用 - 记忆文件存储路径: 支持的格式 | 格式 | 版本 | 内部结构 | 检测方式 | |------|------|---------|---------| | Zen | XMind Zen / 2020+ | ZIP 内含 | 自动检测 | | Legacy | XMind 8 | ZIP 内含 | 自动检测 | 创建新文件时默认使用 Zen 格式;更新已有文件时保留原格式。 Markdown 表示规范 解析后的 Markdown 使用缩进列表式结构,格式如下: 格式说明: - — 工作表标题(多工作表之…