@xmindltd/xmind-cli 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,336 @@
1
+ ---
2
+ name: xmind-file
3
+ description: >-
4
+ Create, validate, and edit local .xmind mind map files via the xmind CLI. Use
5
+ for local structured knowledge maps, planning maps, and visual polish of
6
+ existing .xmind files. This stage is local-file only with no cloud
7
+ collaboration flow and no AI-generated-image workflow. Image attachments may
8
+ use local user files or web-searched files downloaded to disk.
9
+ ---
10
+
11
+ # Xmind File
12
+
13
+ Runtime protocol for local `.xmind` generation and editing.
14
+
15
+ The entry skill owns execution order and delivery gates. Recipes own content.
16
+ Visual owns semantic anchor planning. The CLI owns mechanical execution:
17
+ `generate`, file IO, billing/downgrade, anchors, images, and validation.
18
+
19
+ ## Setup
20
+
21
+ ```bash
22
+ which xmind || npm install -g "$(find ~/.claude /mnt/skills -name 'xmind-cli-*.tgz' 2>/dev/null | head -1)" 2>/dev/null || npm install -g @xmindltd/xmind-cli
23
+ xmind auth status
24
+ ```
25
+
26
+ If unauthenticated, run `xmind auth login` or `xmind auth token <value>`.
27
+ File commands require login.
28
+
29
+ ## Core Boundary
30
+
31
+ - Agent supplies semantic judgment: recipe, markdown, route intent, anchors, and
32
+ image targets.
33
+ - `xmind generate` compiles the semantic spec into a `.xmind`: route gate,
34
+ skeleton/color, billing/downgrade, create, anchors, images, validation, and
35
+ JSON report.
36
+ - `xmind advise`, `create`, `batch`, `image`, and `validate` remain lower-level
37
+ tools for quick maps, edits, repair, and inspection.
38
+ - Do not weaken content or visuals to avoid credits. Choose the right artifact;
39
+ let the CLI charge, downgrade, or report.
40
+ - Sum turn credits from JSON stdout `billing.consumed`; missing `billing` means
41
+ 0.
42
+
43
+ ## Recipe Choice
44
+
45
+ Choose recipe before drafting.
46
+
47
+ Resolve the user's intent before choosing. When needed, offer 2-4
48
+ domain-specific choices:
49
+
50
+ - Full map: richer structure, visual anchors, and selective images; usually
51
+ `recipe/default` or a focused recipe.
52
+ - Quick overview: compact, free-first, `recipe/quick-map`.
53
+ - Timeline narrative: sequence/history, `recipe/timeline-narrative`.
54
+ - Focused analysis: `recipe/swot`, `recipe/comparison-decision`, or
55
+ `recipe/process-playbook` only when the topic naturally matches.
56
+
57
+ For a new map, stop and ask before drafting, researching, loading recipe
58
+ context, or generating when a short generic prompt does not establish the
59
+ artifact shape or depth. Examples include "generate a mind map about X", "X
60
+ company introduction", and "overview of X". Wait for the user's choice.
61
+
62
+ Decision gate:
63
+
64
+ - Choose `recipe/quick-map` without asking when the user explicitly asks for a
65
+ quick, simple, lightweight, compact, free, short, or first-draft map.
66
+ - Choose `recipe/default` without asking when the user explicitly asks for a
67
+ rich, detailed, comprehensive, polished, presentation-ready, research-style,
68
+ or image/anchor-enhanced knowledge map, and no focused recipe fits better.
69
+ - Choose a focused recipe without asking when the requested artifact has a clear
70
+ dominant form: comparison, SWOT, lesson plan, process/playbook, or chronology.
71
+ - Otherwise, ask when both `quick-map` and `default` fit, or a focused recipe
72
+ would meaningfully change the artifact. Broad subject matter and billing
73
+ capability do not determine depth.
74
+
75
+ This does not override CLI/server fallback. If `xmind skill show` returns
76
+ `effective: "quick-map"` because premium recipe access or Xmind credits are not
77
+ available, follow the effective recipe and explain the fallback plainly.
78
+
79
+ ## Context Loading
80
+
81
+ | Need | Load |
82
+ |---|---|
83
+ | Discover capabilities | `xmind skill list` |
84
+ | Rich new map | `xmind skill show markdown-grammar recipe/<chosen> visual --json` |
85
+ | Quick free map | `xmind skill show markdown-grammar recipe/quick-map --json` |
86
+ | Existing-map edit | `xmind skill show edit/guide` |
87
+ | Low-level repair ops | `xmind skill show visual/layout-style visual/node-style` |
88
+ | Work-execution overlay | `xmind skill show task-overlay` |
89
+
90
+ For recipe JSON, record `requested`, `effective`, and `createSkill`. If the CLI
91
+ serves a fallback recipe, draft from `effective` and use its `createSkill`.
92
+
93
+ ## Scratch IO
94
+
95
+ Use stable scratch paths under `/tmp`; do not use `$$`, `$RANDOM`, or `mktemp`
96
+ across commands.
97
+
98
+ - Draft: `/tmp/xmind-draft-<id>.md`
99
+ - Generate spec: `/tmp/xmind-generate-<id>.json`
100
+ - Downloaded/user images: real on-disk files that persist until attachment.
101
+
102
+ After successful delivery, delete only generated scratch markdown/spec. Never
103
+ delete final `.xmind`, user-provided inputs, or persistent downloaded assets
104
+ unless asked.
105
+
106
+ ## Generate Spec
107
+
108
+ For rich generation, write a semantic spec and let the CLI compile it.
109
+
110
+ ```json
111
+ {
112
+ "version": 1,
113
+ "markdown": { "path": "/tmp/xmind-draft-<id>.md" },
114
+ "recipe": {
115
+ "name": "<requested recipe>",
116
+ "effective": "<effective recipe>",
117
+ "createSkill": "<recipe item createSkill>"
118
+ },
119
+ "route": {
120
+ "structuralType": "<radial_overview|mixed_modular|temporal_axis|procedural_flow|matrix_board|causal_ribs|hierarchy_tree|part_whole>",
121
+ "structureCommitment": "<required|preferred|optional>",
122
+ "toneTag": "<tech|nature|retro|elegant|fresh|sweet|vivid|plain>",
123
+ "density": "<light|standard|deep>"
124
+ },
125
+ "baseline": {
126
+ "skeleton": "auto",
127
+ "color": "auto",
128
+ "diversify": true,
129
+ "seed": "<stable id>"
130
+ },
131
+ "anchors": {
132
+ "layout": [],
133
+ "group": [],
134
+ "focus": [],
135
+ "image": []
136
+ }
137
+ }
138
+ ```
139
+
140
+ Anchor families:
141
+
142
+ - `layout`: local relation layouts on `###` or deeper nodes.
143
+ - `group`: `boundary` / `summary` over sibling groups.
144
+ - `focus`: `emphasis`, `callout`, `numbering`, or `relation`.
145
+ - `image`: local file, stable raster URL, or Wikipedia image. Generate attaches
146
+ images last.
147
+
148
+ Use `"auto"` baseline unless the user gave an override or you have a recorded
149
+ reason. The Agent decides anchors semantically; do not invent decorative anchors
150
+ only to satisfy a checklist.
151
+
152
+ ## Semantic Quality Gate
153
+
154
+ Before `generate`, check the draft as content, not just as markdown:
155
+
156
+ - The chosen recipe matches the user goal; do not let `quick-map` replace a
157
+ needed deep map.
158
+ - Top-level branches cover distinct facets and are not broad catch-all buckets.
159
+ - Important branches have visible child structure; notes do not carry the real
160
+ hierarchy.
161
+ - Anchor targets already exist in honest content and can be found by title.
162
+ - The route fields describe the root relation, while anchors describe local
163
+ exceptions.
164
+
165
+ If this gate fails, revise markdown/spec before running the CLI. Mechanical
166
+ validation cannot detect a shallow or semantically fake map.
167
+
168
+ ## Flow A: Rich Generate
169
+
170
+ 1. Load context:
171
+
172
+ ```bash
173
+ xmind skill list
174
+ xmind skill show markdown-grammar recipe/<chosen> visual --json
175
+ ```
176
+
177
+ 2. Draft markdown from the effective recipe.
178
+
179
+ Follow recipe density, shape, semantic signals, notes posture, and self-check.
180
+ First draft the visible heading skeleton, then add selective notes and anchor
181
+ candidates. For `recipe/default`, density is normally `deep`. Write pure
182
+ CommonMark to `/tmp/xmind-draft-<id>.md`.
183
+
184
+ 3. Write `/tmp/xmind-generate-<id>.json`.
185
+
186
+ The route fields are semantic declarations:
187
+
188
+ - `structuralType`: root relation family.
189
+ - `structureCommitment`: how strongly that root relation is required.
190
+ - `toneTag`: palette character.
191
+ - `density`: recipe density, not a skeleton choice.
192
+
193
+ For default maps, normally provide at least one real target in `layout`,
194
+ `group`, `focus`, and `image`, unless the user asked for text-only/no-images
195
+ or the subject has no useful concrete image anchor.
196
+
197
+ 4. Preflight and optionally dry-run:
198
+
199
+ ```bash
200
+ xmind generate check --spec /tmp/xmind-generate-<id>.json
201
+ xmind generate --spec /tmp/xmind-generate-<id>.json --dry-run -o <file>.xmind
202
+ ```
203
+
204
+ Use dry-run for deep maps, premium-capable baselines, or when the baseline
205
+ matters. If the route gate blocks, revise the same markdown/spec.
206
+
207
+ 5. Generate:
208
+
209
+ ```bash
210
+ xmind generate --spec /tmp/xmind-generate-<id>.json -o <file>.xmind
211
+ ```
212
+
213
+ Treat stdout JSON as authoritative. If `validation.ok` is false or any
214
+ `anchors.applied[].success` is false, fix the same markdown/spec and rerun.
215
+ Passing CLI validation is necessary but not sufficient; also re-check the
216
+ semantic gate before delivery.
217
+
218
+ 6. Inspect only when needed:
219
+
220
+ ```bash
221
+ xmind read <file>.xmind
222
+ xmind describe <file>.xmind
223
+ xmind validate <file>.xmind --quiet
224
+ ```
225
+
226
+ ## Flow Q: Quick Free Generate
227
+
228
+ Use when the chosen recipe is `quick-map`.
229
+
230
+ 1. Load:
231
+
232
+ ```bash
233
+ xmind skill list
234
+ xmind skill show markdown-grammar recipe/quick-map --json
235
+ ```
236
+
237
+ 2. Draft compact markdown, usually `light` or `standard`.
238
+
239
+ 3. Pick a free baseline directly:
240
+
241
+ - overview/resource: `MindMap-1`
242
+ - triage/checklist: `Matrix-1`
243
+ - quick-plan/simple-process: `LogicChart-1`
244
+ - simple-timeline: `Timeline-1` or `Timeline-3`
245
+ - hierarchy: `OrgChart-1` or `TreeChart-1`
246
+
247
+ 4. Create and validate:
248
+
249
+ ```bash
250
+ xmind create --from-markdown /tmp/xmind-draft-<id>.md --skeleton <free-name> --color Dawn-#ffffff-MULTI_LINE_COLORS --skill <createSkill> -o <file>.xmind
251
+ xmind validate <file>.xmind --quiet
252
+ ```
253
+
254
+ Run `read`/`describe` only if validation fails, the user asks, or a small
255
+ repair is clearly needed.
256
+
257
+ 5. Communicate the boundary.
258
+
259
+ Tell the user this is a quick overview, not the full rich-map path. Offer to
260
+ regenerate with a fuller recipe if they want deeper titles/notes, visual
261
+ anchors, images, or premium-capable structure.
262
+
263
+ ## Flow B: Edit Existing Map
264
+
265
+ 1. Load `edit/guide`; load `visual` only if the edit changes visual treatment.
266
+ 2. Inspect first:
267
+
268
+ ```bash
269
+ xmind read <file>.xmind
270
+ xmind describe <file>.xmind
271
+ xmind validate <file>.xmind --quiet
272
+ ```
273
+
274
+ 3. Plan against current structure and preserve unrelated user changes.
275
+ 4. Use one `xmind batch` for multi-op edits; use direct commands for single
276
+ edits.
277
+ 5. Re-run `read`, `describe`, and `validate`.
278
+
279
+ ## Images
280
+
281
+ Image inputs can be user-provided local files, stable raster image URLs, or
282
+ Wikipedia page images. Do not use AI-generated images in this skill; use
283
+ `xmind-illustrated-map` for generated-image workflows.
284
+
285
+ Remote image URLs must be public raster images. SVG, private/local-network URLs,
286
+ and non-image payloads are rejected.
287
+
288
+ For Flow A, declare images in `anchors.image` so `xmind generate` attaches them
289
+ last. For edits:
290
+
291
+ ```bash
292
+ xmind image <file>.xmind --topic "<topic title>" --input "<local-image-path>"
293
+ xmind image <file>.xmind --topic "<topic title>" --url "<https-image-url>"
294
+ xmind image <file>.xmind --topic "<topic title>" --wiki "<Wikipedia page title>"
295
+ ```
296
+
297
+ ## Delivery Gate
298
+
299
+ For Flow A:
300
+
301
+ - Effective recipe was loaded and followed.
302
+ - Generate spec points to the scratch markdown and includes `recipe.createSkill`.
303
+ - `xmind generate check` passed.
304
+ - Dry-run ran for non-trivial maps, or was skipped with a reason.
305
+ - Final generate report has `validation.ok: true`.
306
+ - All required `anchors.applied[].success` values are true.
307
+ - Billing was read from `billing.consumed`.
308
+ - Scratch markdown/spec were deleted after success.
309
+
310
+ For Flow Q:
311
+
312
+ - `recipe/quick-map` was loaded and followed.
313
+ - Free skeleton was used unless explicitly overridden.
314
+ - `createSkill` was passed to `xmind create --skill`.
315
+ - `xmind validate` has no structural errors.
316
+
317
+ ## User Communication
318
+
319
+ For non-trivial generation, briefly explain the result in the user's language:
320
+
321
+ - Why the recipe/content shape fits the topic.
322
+ - Which visible nodes or groups motivated major visual features.
323
+ - Whether generation used Xmind credits. Never call them OpenAI, Codex, model,
324
+ or token credits.
325
+
326
+ Use CLI JSON as source of truth, especially `route.skeletonReason`,
327
+ `route.colorReason`, `anchors.applied`, `billing.consumed`, `billing.balance`,
328
+ `billing.unit`, and `downgraded`. If `billing` is missing, treat the turn as 0
329
+ Xmind credits.
330
+
331
+ Offer one or two concrete next actions: deepen a branch, compare recipes, adjust
332
+ images/style, edit an existing `.xmind`, create a lighter/free version, or run
333
+ validation/inspection.
334
+
335
+ Final response: give the file path, validation result, and one or two important
336
+ design choices. Do not dump the full outline unless asked.