# MNote mindmap editing

Use this skill only when the user asks to read, summarize, update, or create an MNote mindmap resource.

Typical triggers:
- The user mentions 思维导图, 脑图, mindmap, KMind, or `.mindmap.json`.
- The current Page AI target is a mindmap resource tab.
- The current page contains a mindmap embed and the task is about that embed.
- The user asks to turn a PDF, Office document, Markdown page, or pasted material into a mindmap.

Rules:
- First call `mnote.context.snapshot` or `mnote.context.resolve_target` when target metadata is needed.
- Prefer the current mindmap resource tab over page embeds when both are present.
- For existing mindmaps, call `mnote.mindmap.fetch` before proposing or applying changes.
- For new mindmaps from PDF or document summaries, convert the source material into a concise hierarchical outline, then call `mnote.mindmap.create_from_outline`.
- Do not write a naked simple-mind-map tree as the final file. MNote mindmap files use an envelope with `data` as the root tree and `view` as runtime view state.
- Keep the root node uid as `root` for new maps unless MNote returns a different root.
- Let MNote generate child node uid values; do not invent duplicate ids.
- Before writing, confirm the run has `read_write` permission and the target resource is inside `allowedResourceIds`.
- After writing or creating a mindmap, read it back with `mnote.mindmap.fetch` and report the changed `.mindmap.json` path.
- If authorization is missing, ask the user to grant access instead of guessing a path.

Current apply_ops contract:
- Supported operations are `updateText` / `updateNode`, `insertChild` / `addChild`, and `deleteNode`.
- `updateText` / `updateNode` require `nodeId` (or `node_id` / `id`) and `text` (or `title`).
- `insertChild` / `addChild` require `parentId` (or `parent_id` / `nodeId`) and a child node payload.
- `deleteNode` requires `nodeId` (or `node_id` / `id`) and must never target the root node.
- Unknown operations are rejected; do not assume extra edit verbs exist.
- Prefer small, reviewable edits. Keep node text concise and split long prose into child nodes.
- Long text should be summarized into short phrases or child nodes rather than embedded as a single paragraph.
- Respect `dryRun` and revision checks when the caller provides them.

Mindmap outline format:
- Use one central root topic as the `title`; it should name the subject, not explain it in a paragraph.
- Use first-level children for the major categories or sections radiating from the root.
- Use concise keywords or short phrases for node text. Avoid long paragraphs, full prose summaries, and multiple sentences inside one node.
- Put one idea in each node. Split causes, decisions, examples, and evidence into child nodes instead of joining them with punctuation.
- Keep each level scannable: prefer 3-8 sibling branches unless the source structure requires more.
- Preserve hierarchy with `children`; do not simulate structure by embedding Markdown lists or newline-separated text in a node.
- Keep citations, page numbers, and source metadata in `sourceRefs` or nearby metadata when possible, rather than cramming them into visible node text.

PDF or document to mindmap workflow:
1. Identify the source resource and target page.
2. Extract or receive a title plus outline from the source material.
3. Keep the outline small enough to be useful: preserve chapters, decisions, key concepts, and relationships; remove repeated prose.
4. Call `mnote.mindmap.create_from_outline` with `title`, `outline`, `sourceRefs`, and the target resource path when provided.
5. Verify the created resource by fetching it and checking the root title and first-level branches.
