felo-ai 0.2.50 → 0.2.52

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.
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  </p>
6
6
 
7
7
  <p align="center">
8
- <strong>Ask anything. Get current answers. Generate slides from a prompt.</strong>
8
+ <strong>Ask anything. Get current answers. Generate slides and mindmaps from a prompt.</strong>
9
9
  </p>
10
10
 
11
11
  <p align="center">
@@ -15,7 +15,7 @@
15
15
  <a href="./felo-search/LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg?style=for-the-badge" alt="MIT License"></a>
16
16
  </p>
17
17
 
18
- **Felo AI CLI** — Real-time search, PPT generation, web fetch, YouTube subtitles, X (Twitter) search, SuperAgent conversation, and Twitter writing from the terminal. Also works as Claude Code skills. Supports Chinese, English, Japanese, and Korean.
18
+ **Felo AI CLI** — Real-time search, PPT generation, mindmap creation, web fetch, YouTube subtitles, and X (Twitter) search, SuperAgent conversation, and Twitter writing from the terminal. Also works as Claude Code skills. Supports Chinese, English, Japanese, and Korean.
19
19
 
20
20
  <p align="center">
21
21
  <a href="https://felo.ai">Felo AI</a> · <a href="https://openapi.felo.ai/docs/">Docs</a> · <a href="https://openapi.felo.ai/docs/api-reference/v2/chat.html">API Reference</a> · <a href="./docs/EXAMPLES.md">Examples</a> · <a href="./docs/FAQ.md">FAQ</a> · <a href="https://clawhub.ai/u/wangzhiming1999">ClawHub</a> · <a href="https://discord.gg/9W8NubHA">Discord</a> · <a href="https://x.com/felo_ai">X (Twitter)</a>
@@ -50,6 +50,7 @@ $env:FELO_API_KEY="..." # Windows (PowerShell)
50
50
  | ---------------------------------------- | ----------------------------------------------------- |
51
51
  | `felo search "<query>"` | Search for current info (weather, news, prices, etc.) |
52
52
  | `felo slides "<prompt>"` | Generate PPT; returns link when done |
53
+ | `felo mindmap "<query>"` | Generate mindmap; returns link immediately |
53
54
  | `felo web-fetch --url <url>` | Fetch webpage content (markdown/text/html) |
54
55
  | `felo youtube-subtitling -v <url-or-id>` | Fetch YouTube video subtitles |
55
56
  | `felo x "<query>"` | Search X (Twitter) tweets, users, and replies |
@@ -78,6 +79,15 @@ felo slides "Felo product intro, 3 slides"
78
79
  felo slides "Q4 2024 business review, 10 pages" --poll-timeout 300
79
80
  ```
80
81
 
82
+ **Mindmap**
83
+
84
+ ```bash
85
+ felo mindmap "AI trends in 2024"
86
+ felo mindmap "Project timeline" --layout TIMELINE
87
+ felo mindmap "Problem analysis" --layout FISHBONE --json
88
+ felo mindmap-layouts # List available layouts
89
+ ```
90
+
81
91
  **Web Fetch** — [full options →](./felo-web-fetch/README.md)
82
92
 
83
93
  ```bash
@@ -155,9 +165,9 @@ node felo-superAgent/scripts/run_superagent.mjs \
155
165
 
156
166
  ```bash
157
167
  # Use as Claude Code skill
158
- /felo-superagent What is the latest news about AI?
159
- /felo-superagent Write a tweet about quantum computing
160
- /felo-superagent Design a logo for my coffee shop
168
+ /felo-superAgent What is the latest news about AI?
169
+ /felo-superAgent Write a tweet about quantum computing
170
+ /felo-superAgent Design a logo for my coffee shop
161
171
  ```
162
172
 
163
173
  ```bash
@@ -180,7 +190,7 @@ felo style-library IMAGE --accept-language zh-Hans
180
190
 
181
191
  ## Skills Overview
182
192
 
183
- 9 skills across search, content generation, web scraping, social media, knowledge base, shopping advice, Twitter writing, and AI conversation:
193
+ 10 skills across search, content generation, web scraping, social media, knowledge base, and shopping advice:
184
194
 
185
195
  | Skill | Description | Docs |
186
196
  |---|---|---|
@@ -193,6 +203,7 @@ felo style-library IMAGE --accept-language zh-Hans
193
203
  | **apple-buy-advisor** | Research and compare Apple products before you buy | [→](./apple-buy-advisor/) |
194
204
  | **felo-twitter-writer** | Analyze tweet style DNA; compose tweets, threads, X posts with brand style | [→](./felo-twitter-writer/README.md) |
195
205
  | **felo-superAgent** | AI conversation with real-time streaming, brand style support, continuous threads | [→](./felo-superAgent/README.md) |
206
+ | **felo-mindmap** | Generate mindmaps with various layouts | [→](./felo-mindmap/) |
196
207
 
197
208
  ---
198
209
 
@@ -204,16 +215,17 @@ These two skills work together and share the style library. Here is how Claude u
204
215
 
205
216
  ```bash
206
217
  # Via ClawHub
207
- clawhub install felo-superAgent
218
+ # felo-twitter-writer depends on felo-superAgent + felo-livedoc; felo-superAgent depends on felo-livedoc
208
219
  clawhub install felo-twitter-writer
209
- clawhub install felo-x-search
220
+ clawhub install felo-superAgent
210
221
  clawhub install felo-livedoc
222
+ clawhub install felo-x-search
211
223
 
212
224
  # Manual
213
- cp -r felo-superAgent ~/.claude/skills/
214
225
  cp -r felo-twitter-writer ~/.claude/skills/
215
- cp -r felo-x-search ~/.claude/skills/
226
+ cp -r felo-superAgent ~/.claude/skills/
216
227
  cp -r felo-livedoc ~/.claude/skills/
228
+ cp -r felo-x-search ~/.claude/skills/
217
229
  ```
218
230
 
219
231
  ### felo-twitter-writer
@@ -263,10 +275,10 @@ If the style library is empty, Claude skips the selection step silently.
263
275
  Trigger keywords: `superagent`, `super agent`, `stream chat`, `streaming conversation`, `write a tweet`, `create a logo`, `product image`
264
276
 
265
277
  ```
266
- /felo-superagent What is the latest news about AI?
267
- /felo-superagent Write a tweet about quantum computing
268
- /felo-superagent Design a logo for my coffee shop
269
- /felo-superagent Generate a product image for wireless headphones
278
+ /felo-superAgent What is the latest news about AI?
279
+ /felo-superAgent Write a tweet about quantum computing
280
+ /felo-superAgent Design a logo for my coffee shop
281
+ /felo-superAgent Generate a product image for wireless headphones
270
282
  ```
271
283
 
272
284
  **What Claude does automatically for skill-based conversations:**
@@ -296,13 +308,21 @@ For skill-based new conversations, Claude fetches the matching style library, pr
296
308
  # Via ClawHub (recommended)
297
309
  clawhub install felo-search
298
310
  clawhub install felo-slides
311
+ clawhub install felo-mindmap
299
312
  clawhub install felo-web-fetch
300
313
  clawhub install felo-youtube-subtitling
301
314
  clawhub install felo-x-search
302
315
  clawhub install felo-livedoc
303
316
  clawhub install apple-buy-advisor
317
+
318
+ # felo-superAgent depends on felo-livedoc — install both:
304
319
  clawhub install felo-superAgent
305
- # felo-twitter-writer: no clawhub.json yet — use manual install below
320
+ clawhub install felo-livedoc
321
+
322
+ # felo-twitter-writer depends on felo-superAgent and felo-livedoc — install all three:
323
+ clawhub install felo-twitter-writer
324
+ clawhub install felo-superAgent
325
+ clawhub install felo-livedoc
306
326
  ```
307
327
 
308
328
  ```bash
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Felo Mindmap Skill Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,71 @@
1
+ # Felo Mindmap
2
+
3
+ Generate mindmaps with Felo Mindmap API in Claude Code.
4
+
5
+ ## Features
6
+
7
+ - Create mindmaps from any topic or question
8
+ - Support for 6 layout types: MIND_MAP, TIMELINE, FISHBONE, etc.
9
+ - Add mindmaps to existing LiveDoc
10
+ - Simple synchronous API (no waiting)
11
+
12
+ ## Setup
13
+
14
+ 1. Get your API key from [felo.ai](https://felo.ai) -> Settings -> API Keys
15
+ 2. Set environment variable:
16
+
17
+ ```bash
18
+ export FELO_API_KEY="your-api-key-here"
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ ### Basic Usage
24
+
25
+ ```bash
26
+ node felo-mindmap/scripts/run_mindmap_task.mjs --query "Artificial Intelligence trends in 2024"
27
+ ```
28
+
29
+ ### With Layout Type
30
+
31
+ ```bash
32
+ node felo-mindmap/scripts/run_mindmap_task.mjs --query "Project timeline" --layout TIMELINE
33
+ ```
34
+
35
+ ### With Existing LiveDoc
36
+
37
+ ```bash
38
+ node felo-mindmap/scripts/run_mindmap_task.mjs --query "Meeting notes" --livedoc-short-id "abc123"
39
+ ```
40
+
41
+ ### JSON Output
42
+
43
+ ```bash
44
+ node felo-mindmap/scripts/run_mindmap_task.mjs --query "Topic" --json
45
+ ```
46
+
47
+ ## Layout Types
48
+
49
+ | Layout | Description |
50
+ |--------|-------------|
51
+ | `MIND_MAP` | Classic mind map (default) |
52
+ | `LOGICAL_STRUCTURE` | Logical structure diagram |
53
+ | `ORGANIZATION_STRUCTURE` | Organization chart |
54
+ | `CATALOG_ORGANIZATION` | Catalog organization chart |
55
+ | `TIMELINE` | Timeline diagram |
56
+ | `FISHBONE` | Fishbone diagram |
57
+
58
+ ## CLI Options
59
+
60
+ | Option | Description |
61
+ |--------|-------------|
62
+ | `--query <text>` | Mindmap topic (required) |
63
+ | `--layout <type>` | Layout type (default: MIND_MAP) |
64
+ | `--livedoc-short-id <id>` | Add to existing LiveDoc |
65
+ | `--timeout <seconds>` | Request timeout (default: 60) |
66
+ | `--json` | Output as JSON |
67
+ | `--help` | Show help |
68
+
69
+ ## License
70
+
71
+ MIT
@@ -0,0 +1,172 @@
1
+ ---
2
+ name: felo-mindmap
3
+ description: "Generate mindmaps with Felo Mindmap API in Claude Code. Use when users ask to create/make/generate mindmaps, mind maps, or thinking maps, or when explicit commands like /felo-mindmap are used. Handles API key check, mindmap creation with various layouts, and final mindmap_url output."
4
+ ---
5
+
6
+ # Felo Mindmap Skill
7
+
8
+ ## When to Use
9
+
10
+ Trigger this skill for requests about creating mindmap files:
11
+
12
+ - Create/generate mindmaps from a topic or question
13
+ - Turn ideas into a structured mindmap
14
+ - Build a mindmap with different layout types (timeline, fishbone, etc.)
15
+ - Export mindmap content into a shareable link
16
+
17
+ Trigger keywords:
18
+
19
+ - Chinese prompts about making mindmaps (思维导图, 脑图)
20
+ - English: mindmap, mind map, thinking map, generate mindmap
21
+ - Explicit commands: `/felo-mindmap`, "use felo mindmap"
22
+
23
+ Do NOT use this skill for:
24
+
25
+ - Real-time information lookup (use `felo-search`)
26
+ - Questions about local codebase files
27
+ - Pure text tasks that do not require mindmap generation
28
+
29
+ ## Setup
30
+
31
+ ### 1. Get API key
32
+
33
+ 1. Visit [felo.ai](https://felo.ai)
34
+ 2. Open Settings -> API Keys
35
+ 3. Create and copy your API key
36
+
37
+ ### 2. Configure environment variable
38
+
39
+ Linux/macOS:
40
+
41
+ ```bash
42
+ export FELO_API_KEY="your-api-key-here"
43
+ ```
44
+
45
+ Windows PowerShell:
46
+
47
+ ```powershell
48
+ $env:FELO_API_KEY="your-api-key-here"
49
+ ```
50
+
51
+ ## How to Execute
52
+
53
+ Use Bash tool commands and follow this workflow exactly.
54
+
55
+ ### Step 1: Precheck API key
56
+
57
+ ```bash
58
+ if [ -z "$FELO_API_KEY" ]; then
59
+ echo "ERROR: FELO_API_KEY not set"
60
+ exit 1
61
+ fi
62
+ ```
63
+
64
+ If key is missing, stop and return setup instructions.
65
+
66
+ ### Step 2: Run Node Script
67
+
68
+ Use the bundled script:
69
+
70
+ ```bash
71
+ node felo-mindmap/scripts/run_mindmap_task.mjs \
72
+ --query "USER_PROMPT_HERE" \
73
+ --timeout 60
74
+ ```
75
+
76
+ To specify a layout type:
77
+
78
+ ```bash
79
+ node felo-mindmap/scripts/run_mindmap_task.mjs \
80
+ --query "USER_PROMPT_HERE" \
81
+ --layout "TIMELINE" \
82
+ --timeout 60
83
+ ```
84
+
85
+ Available layout types:
86
+ - `MIND_MAP` (default) - Classic mind map
87
+ - `LOGICAL_STRUCTURE` - Logical structure diagram
88
+ - `ORGANIZATION_STRUCTURE` - Organization chart
89
+ - `CATALOG_ORGANIZATION` - Catalog organization chart
90
+ - `TIMELINE` - Timeline diagram
91
+ - `FISHBONE` - Fishbone diagram
92
+
93
+ To add mindmap to an existing LiveDoc:
94
+
95
+ ```bash
96
+ node felo-mindmap/scripts/run_mindmap_task.mjs \
97
+ --query "USER_PROMPT_HERE" \
98
+ --livedoc-short-id "EXISTING_LIVEDOC_ID"
99
+ ```
100
+
101
+ Script behavior:
102
+
103
+ - Creates mindmap via `POST https://openapi.felo.ai/v2/mindmap`
104
+ - Returns immediately (synchronous API, no polling needed)
105
+ - Prints `mindmap_url` on success
106
+
107
+ Optional debug output:
108
+
109
+ ```bash
110
+ node felo-mindmap/scripts/run_mindmap_task.mjs \
111
+ --query "USER_PROMPT_HERE" \
112
+ --json
113
+ ```
114
+
115
+ This outputs structured JSON including:
116
+
117
+ - `resource_id`
118
+ - `status`
119
+ - `mindmap_url`
120
+ - `livedoc_short_id`
121
+
122
+ ### Step 3: Return structured result
123
+
124
+ On success, return:
125
+
126
+ - `mindmap_url` immediately
127
+ - if `--json` is used, also include `resource_id`, `livedoc_short_id`
128
+
129
+ ## Output Format
130
+
131
+ Use this response structure:
132
+
133
+ ```markdown
134
+ ## Mindmap Generation Result
135
+
136
+ - Resource ID: <resource_id>
137
+ - Status: <status>
138
+ - Mindmap URL: <mindmap_url>
139
+ - LiveDoc Short ID: <livedoc_short_id>
140
+ ```
141
+
142
+ Error format:
143
+
144
+ ```markdown
145
+ ## Mindmap Generation Failed
146
+
147
+ - Error Type: <error code or category>
148
+ - Message: <readable message>
149
+ - Suggested Action: <next step>
150
+ ```
151
+
152
+ ## Error Handling
153
+
154
+ Known API error codes:
155
+
156
+ - `INVALID_API_KEY` (401): key invalid or revoked
157
+ - `MINDMAP_CREATE_FAILED` (502): mindmap creation failed
158
+ - `LIVEDOC_CREATE_FAILED` (502): failed to create LiveDoc
159
+ - `LIVEDOC_NOT_FOUND` (404): specified LiveDoc not found
160
+ - `LLM_SERVICE_UNAVAILABLE` (503): LLM service is unavailable
161
+ - `LLM_REQUEST_TIMEOUT` (504): LLM request timed out
162
+
163
+ ## Important Notes
164
+
165
+ - Always execute this skill when user intent is mindmap generation.
166
+ - The API is synchronous - no polling required.
167
+ - Keep API calls minimal: one request per mindmap.
168
+
169
+ ## References
170
+
171
+ - [Felo Mindmap API](https://openapi.felo.ai/docs/api-reference/v2/mindmap.html)
172
+ - [Felo Open Platform](https://openapi.felo.ai/docs/)
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "Felo Mindmap",
3
+ "tagline": "Generate mindmaps with Felo Mindmap API in Claude Code",
4
+ "description": "Felo Mindmap creates mindmaps from a prompt using the Felo Mindmap API. Supports multiple layout types (MIND_MAP, TIMELINE, FISHBONE, etc.) and LiveDoc integration. Use from Claude Code when users ask to create or generate mindmaps.",
5
+ "category": "productivity",
6
+ "tags": ["felo", "mindmap", "mind map", "thinking map", "api", "claude-code"],
7
+ "version": "1.0.0",
8
+ "license": "MIT",
9
+ "pricing": "free",
10
+ "support_url": "https://github.com/Felo-Inc/felo-skills/issues",
11
+ "homepage": "https://github.com/Felo-Inc/felo-skills"
12
+ }
@@ -0,0 +1,230 @@
1
+ #!/usr/bin/env node
2
+
3
+ const DEFAULT_API_BASE = 'https://openapi.felo.ai';
4
+ const DEFAULT_TIMEOUT_SEC = 60;
5
+ const DEFAULT_LAYOUT = 'MIND_MAP';
6
+
7
+ const VALID_LAYOUTS = [
8
+ 'MIND_MAP',
9
+ 'LOGICAL_STRUCTURE',
10
+ 'ORGANIZATION_STRUCTURE',
11
+ 'CATALOG_ORGANIZATION',
12
+ 'TIMELINE',
13
+ 'FISHBONE',
14
+ ];
15
+
16
+ function usage() {
17
+ console.error(
18
+ [
19
+ 'Usage:',
20
+ ' node felo-mindmap/scripts/run_mindmap_task.mjs --query "your prompt" [options]',
21
+ '',
22
+ 'Options:',
23
+ ' --query <text> Mindmap topic (required)',
24
+ ' --layout <type> Layout type (default: MIND_MAP)',
25
+ ' --livedoc-short-id <id> Add to existing LiveDoc',
26
+ ' --timeout <seconds> Request timeout, default 60',
27
+ ' --json Print JSON output',
28
+ ' --help Show this help',
29
+ '',
30
+ 'Layout Types:',
31
+ ' MIND_MAP Classic mind map (default)',
32
+ ' LOGICAL_STRUCTURE Logical structure diagram',
33
+ ' ORGANIZATION_STRUCTURE Organization chart',
34
+ ' CATALOG_ORGANIZATION Catalog organization chart',
35
+ ' TIMELINE Timeline diagram',
36
+ ' FISHBONE Fishbone diagram',
37
+ ].join('\n')
38
+ );
39
+ }
40
+
41
+ function parseArgs(argv) {
42
+ const out = {
43
+ query: '',
44
+ layout: DEFAULT_LAYOUT,
45
+ livedocShortId: '',
46
+ timeoutSec: DEFAULT_TIMEOUT_SEC,
47
+ json: false,
48
+ };
49
+
50
+ for (let i = 0; i < argv.length; i += 1) {
51
+ const a = argv[i];
52
+ if (a === '--help' || a === '-h') {
53
+ out.help = true;
54
+ } else if (a === '--json') {
55
+ out.json = true;
56
+ } else if (a === '--query') {
57
+ out.query = argv[i + 1] ?? '';
58
+ i += 1;
59
+ } else if (a === '--layout') {
60
+ out.layout = argv[i + 1] ?? '';
61
+ i += 1;
62
+ } else if (a === '--livedoc-short-id') {
63
+ out.livedocShortId = argv[i + 1] ?? '';
64
+ i += 1;
65
+ } else if (a === '--timeout') {
66
+ out.timeoutSec = Number.parseInt(argv[i + 1] ?? '', 10);
67
+ i += 1;
68
+ } else if (!a.startsWith('-') && !out.query) {
69
+ out.query = a;
70
+ }
71
+ }
72
+
73
+ if (!Number.isFinite(out.timeoutSec) || out.timeoutSec <= 0) {
74
+ out.timeoutSec = DEFAULT_TIMEOUT_SEC;
75
+ }
76
+
77
+ return out;
78
+ }
79
+
80
+ function getMessage(payload) {
81
+ return (
82
+ payload?.message ||
83
+ payload?.error ||
84
+ payload?.msg ||
85
+ payload?.code ||
86
+ 'Unknown error'
87
+ );
88
+ }
89
+
90
+ function isApiError(payload) {
91
+ const status = payload?.status;
92
+ const code = payload?.code;
93
+ if (typeof status === 'string' && status.toLowerCase() === 'error') return true;
94
+ if (typeof code === 'string' && code && code.toUpperCase() !== 'OK') return true;
95
+ return false;
96
+ }
97
+
98
+ async function fetchJson(url, init, timeoutMs) {
99
+ const controller = new AbortController();
100
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
101
+ try {
102
+ const res = await fetch(url, { ...init, signal: controller.signal });
103
+ let body = {};
104
+ try {
105
+ body = await res.json();
106
+ } catch {
107
+ body = {};
108
+ }
109
+
110
+ if (!res.ok) {
111
+ throw new Error(`HTTP ${res.status}: ${getMessage(body)}`);
112
+ }
113
+ if (isApiError(body)) {
114
+ throw new Error(getMessage(body));
115
+ }
116
+ return body;
117
+ } finally {
118
+ clearTimeout(timer);
119
+ }
120
+ }
121
+
122
+ async function createMindmap(apiKey, apiBase, query, layout, livedocShortId, timeoutMs) {
123
+ const reqBody = { query, layout };
124
+ if (livedocShortId) {
125
+ reqBody.livedoc_short_id = livedocShortId;
126
+ }
127
+
128
+ const payload = await fetchJson(
129
+ `${apiBase}/v2/mindmap`,
130
+ {
131
+ method: 'POST',
132
+ headers: {
133
+ Accept: 'application/json',
134
+ Authorization: `Bearer ${apiKey}`,
135
+ 'Content-Type': 'application/json',
136
+ },
137
+ body: JSON.stringify(reqBody),
138
+ },
139
+ timeoutMs
140
+ );
141
+
142
+ const data = payload?.data ?? {};
143
+ return data;
144
+ }
145
+
146
+ async function main() {
147
+ const args = parseArgs(process.argv.slice(2));
148
+ if (args.help) {
149
+ usage();
150
+ process.exit(0);
151
+ }
152
+ if (!args.query) {
153
+ usage();
154
+ process.exit(1);
155
+ }
156
+
157
+ const apiKey = process.env.FELO_API_KEY?.trim();
158
+ if (!apiKey) {
159
+ console.error('ERROR: FELO_API_KEY not set');
160
+ console.error('');
161
+ console.error('Setup instructions:');
162
+ console.error('1. Visit https://felo.ai');
163
+ console.error('2. Open Settings -> API Keys');
164
+ console.error('3. Create and copy your API key');
165
+ console.error('4. Set environment variable: export FELO_API_KEY="your-api-key"');
166
+ process.exit(1);
167
+ }
168
+
169
+ // Validate layout type
170
+ const layoutUpper = args.layout.toUpperCase();
171
+ if (!VALID_LAYOUTS.includes(layoutUpper)) {
172
+ console.error(`ERROR: Invalid layout type "${args.layout}"`);
173
+ console.error('');
174
+ console.error('Available layout types:');
175
+ VALID_LAYOUTS.forEach((l) => console.error(` - ${l}`));
176
+ process.exit(1);
177
+ }
178
+
179
+ const apiBase = (process.env.FELO_API_BASE?.trim() || DEFAULT_API_BASE).replace(/\/$/, '');
180
+ const timeoutMs = args.timeoutSec * 1000;
181
+
182
+ try {
183
+ const data = await createMindmap(
184
+ apiKey,
185
+ apiBase,
186
+ args.query,
187
+ layoutUpper,
188
+ args.livedocShortId,
189
+ timeoutMs
190
+ );
191
+
192
+ if (args.json) {
193
+ console.log(
194
+ JSON.stringify(
195
+ {
196
+ status: 'ok',
197
+ data: {
198
+ resource_id: data.resource_id ?? null,
199
+ mindmap_status: data.status ?? null,
200
+ mindmap_url: data.mindmap_url ?? null,
201
+ livedoc_short_id: data.livedoc_short_id ?? null,
202
+ message: data.message ?? null,
203
+ },
204
+ },
205
+ null,
206
+ 2
207
+ )
208
+ );
209
+ } else {
210
+ console.log(data.mindmap_url || data.message || 'Mindmap created successfully');
211
+ }
212
+ } catch (err) {
213
+ const errMsg = err?.message || err;
214
+ console.error(`ERROR: ${errMsg}`);
215
+
216
+ // Provide helpful guidance for known error patterns
217
+ if (errMsg.includes('401') || errMsg.includes('INVALID_API_KEY')) {
218
+ console.error('');
219
+ console.error('Your API key may be invalid or expired.');
220
+ console.error('Please check your API key at https://felo.ai -> Settings -> API Keys');
221
+ } else if (errMsg.includes('timeout') || errMsg.includes('AbortError')) {
222
+ console.error('');
223
+ console.error('Request timed out. Try increasing --timeout or retry later.');
224
+ }
225
+
226
+ process.exit(1);
227
+ }
228
+ }
229
+
230
+ main();
@@ -177,7 +177,7 @@ node felo-superAgent/scripts/run_superagent.mjs \
177
177
  --query "Write a tweet about AI trends" \
178
178
  --live-doc-id "LIVE_DOC_ID" \
179
179
  --skill-id twitter-writer \
180
- --ext '{"brand_style_requirement":"Style name: darioamodei\nStyle labels: Thoughtful long-form essays\nStyle DNA: # Dario Amodei (@DarioAmodei) Tweet Writing Style DNA\n\n## 风格速写\nDario writes like a serious intellectual...(full content)"}' \
180
+ --ext '{"brand_style_requirement":"Style name: darioamodei\nStyle labels: Thoughtful long-form essays\nStyle DNA: # Dario Amodei (@DarioAmodei) Tweet Writing Style DNA\n\n## Style Overview\nDario writes like a serious intellectual...(full content)"}' \
181
181
  --accept-language en
182
182
  ```
183
183
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: felo-superAgent
3
- description: "Felo SuperAgent API: AI conversation with real-time SSE streaming on a persistent LiveDoc canvas. Use when users want SuperAgent chat, continuous conversation, logo/branding design, or e-commerce product images. Do NOT use for tweet/X post writing — use felo-twitter-writer instead. Explicit commands: /felo-superagent."
3
+ description: "Felo SuperAgent API: AI conversation with real-time SSE streaming on a persistent LiveDoc canvas. Use when users want SuperAgent chat, continuous conversation, logo/branding design, or e-commerce product images. Do NOT use for tweet/X post writing — use felo-twitter-writer instead. Explicit commands: /felo-superAgent."
4
4
  ---
5
5
 
6
6
  # Felo SuperAgent Skill
@@ -11,7 +11,7 @@ These rules are mandatory. Violating any of them will produce incorrect behavior
11
11
 
12
12
  1. **ALWAYS use `--json` flag.** The script MUST run in JSON mode (`--json`). In Claude Code's Bash tool, stdout is always captured — it never streams directly to the user. JSON mode returns the full answer in a structured response that Claude can then output as text. State IDs are extracted from the JSON response fields `thread_short_id` and `live_doc_short_id`.
13
13
 
14
- 2. **ALWAYS output the answer directly as text.** After the script finishes, read `data.answer` from the JSON output and print it verbatim as your response text. Do NOT summarize, paraphrase, or add commentary around it. Output it exactly as-is so the user sees the full content.
14
+ 2. **ALWAYS output the answer directly as text.** After the script finishes, read `data.answer` from the JSON output and print it verbatim as your response text. Do NOT summarize, paraphrase, or add commentary around it. Output it exactly as-is so the user sees the full content. Then, if `data.image_urls` is non-empty, append image links immediately after, formatted as one line per image: `[title](url)`.
15
15
 
16
16
  3. **`--live-doc-id` is REQUIRED when creating a conversation.** Never call `run_superagent.mjs` without `--live-doc-id`. If you do not have one yet, obtain it first (see Step 2 below).
17
17
 
@@ -69,7 +69,7 @@ Trigger this skill when users want:
69
69
  - Traditional Chinese (pinyin): chao ji zhu shou, liu shi dui hua, lian xu dui hua, zhui wen, she ji logo, pin pai she ji, dian shang tu pian
70
70
  - Japanese (romaji): suupaa eejento, sutoriimingu kaiwa, keizoku kaiwa, rogo sakusei, shouhin gazou
71
71
 
72
- **Explicit commands:** `/felo-superagent`, "use felo superagent", "felo superagent"
72
+ **Explicit commands:** `/felo-superAgent`, "use felo superagent", "felo superagent"
73
73
 
74
74
  **Do NOT use for:**
75
75
 
@@ -233,58 +233,55 @@ If this is a follow-up (`--thread-id` is set), skip this step entirely. `--skill
233
233
 
234
234
  **4.5a. If the user has already specified a style** (by name, or by pasting a style block), use it directly — skip to 4.5d.
235
235
 
236
- **4.5b. Fetch the style list:**
236
+ **4.5b. Fetch the style list (names only):**
237
237
 
238
- Use the category that matches the skill:
239
-
240
- | Skill ID | `--category` |
241
- |---|---|
242
- | `twitter-writer` | `TWITTER` |
243
- | `logo-and-branding` | `IMAGE` |
244
- | `ecommerce-product-image` | `IMAGE` |
245
-
246
- Pass `--accept-language` matching the user's language (same value used for SuperAgent).
238
+ IMPORTANT: Style DNA content is very large. Always use `--json` and extract only names/labels via Node.js to avoid Bash tool output truncation. Never call `run_style_library.mjs` without `--json` for listing purposes.
247
239
 
248
240
  ```bash
249
241
  # For twitter-writer
250
- node felo-superAgent/scripts/run_style_library.mjs --category TWITTER --accept-language en
242
+ node felo-superAgent/scripts/run_style_library.mjs --category TWITTER --accept-language en --json | node -e "
243
+ const d=require('fs').readFileSync('/dev/stdin','utf8');
244
+ const j=JSON.parse(d);
245
+ const list=j.list||[];
246
+ const user=list.filter(s=>!s.recommended);
247
+ const rec=list.filter(s=>s.recommended);
248
+ if(user.length){console.log('[Your styles]');user.forEach((s,i)=>{const labels=(s.content?.labels?.en||[]).join(', ');console.log((i+1)+'. '+s.name+(labels?' — '+labels:''));});}
249
+ if(rec.length){console.log('[Recommended styles]');rec.forEach((s,i)=>{const labels=(s.content?.labels?.en||[]).join(', ');console.log((user.length+i+1)+'. '+s.name+(labels?' — '+labels:''));});}
250
+ if(!list.length)console.log('(No styles found)');
251
+ "
251
252
 
252
253
  # For logo-and-branding or ecommerce-product-image
253
- node felo-superAgent/scripts/run_style_library.mjs --category IMAGE --accept-language en
254
+ node felo-superAgent/scripts/run_style_library.mjs --category IMAGE --accept-language en --json | node -e "
255
+ const d=require('fs').readFileSync('/dev/stdin','utf8');
256
+ const j=JSON.parse(d);
257
+ const list=j.list||[];
258
+ if(list.length){list.forEach((s,i)=>{const labels=(s.content?.labels?.en||s.content?.tags?.en||[]).join(', ');console.log((i+1)+'. '+s.name+(labels?' — '+labels:''));});}
259
+ else console.log('(No styles found)');
260
+ "
254
261
  ```
255
262
 
256
- The output lists styles in this format, one block per style separated by a blank line:
257
-
258
- ```
259
- Style name: darioamodei
260
- Style labels: Thoughtful long-form essays
261
- Style DNA: # Dario Amodei (@DarioAmodei) Tweet Writing Style DNA
262
- ...(full content)
263
+ Replace `en` with the matching `--accept-language` value for the user's language (`zh`, `ja`, `ko`, `en`). Also update the `.labels?.en` reference in the node script to match (e.g. `.labels?.zh` for Chinese).
263
264
 
264
- Style name: Casual & Witty
265
- Style labels: humor, relatable
266
- Style DNA: ...(full content)
267
- Cover file ID: file_abc123
268
- ```
265
+ **4.5c. Present the styles to the user and ask them to choose:**
269
266
 
270
- Notes:
271
- - `Style labels` is omitted if no labels exist for this entry.
272
- - `Style DNA` is the full text of `content.styleDna` (TWITTER type). Do NOT truncate it.
273
- - `Cover file ID` is omitted if the value is null/empty.
267
+ Output the COMPLETE list as plain text — every style returned, numbered sequentially. NEVER use the `AskUserQuestion` tool (it limits to 4 options and will silently drop styles). NEVER pre-select or filter styles on behalf of the user. Always append a "no preference" option last. Wait for the user's plain-text reply before proceeding.
274
268
 
275
- User-created styles appear first, followed by recommended styles.
269
+ Example output:
270
+ ```
271
+ Here are the available writing styles — choosing one will make the output more accurate:
276
272
 
277
- **4.5c. Present the styles to the user and ask them to choose:**
273
+ [Your styles]
274
+ 1. My Bold Voice — bold, provocative
278
275
 
279
- Show the list (style names only is sufficient) and ask which one to use. Wait for the user's selection before proceeding.
276
+ [Recommended styles]
277
+ 2. darioamodei — Thoughtful long-form essays
278
+ 3. Casual & Witty — humor, relatable
279
+ ...(ALL styles listed, none omitted)
280
280
 
281
- Example prompt to user:
282
- > Here are the available Twitter writing styles. Which one would you like to use?
283
- > 1. Casual & Witty (your style)
284
- > 2. Professional Thought Leader (recommended)
285
- > 3. No style preference — use default
281
+ 0. No preference — use default style
282
+ ```
286
283
 
287
- If the user picks "no preference" or the list is empty, proceed to Step 5 without `--ext`.
284
+ If the user picks "no preference" (0) or the list is empty, proceed to Step 5 without `--ext`.
288
285
 
289
286
  **4.5d. Build the `--ext` value:**
290
287
 
@@ -375,7 +372,14 @@ After the script finishes, parse the JSON output:
375
372
  "answer": "...",
376
373
  "thread_short_id": "CmYpuGwBgCnrUdDx5ZtmxA",
377
374
  "live_doc_short_id": "QPetunwpGnkKuZHStP7gwt",
378
- "live_doc_url": "https://felo.ai/livedoc/QPetunwpGnkKuZHStP7gwt"
375
+ "live_doc_url": "https://felo.ai/livedoc/QPetunwpGnkKuZHStP7gwt",
376
+ "image_urls": [
377
+ {
378
+ "url": "https://...",
379
+ "title": "Image title",
380
+ "file_id": "b9e5be11-7686-4aa8-ae6c-9876511a7b5c"
381
+ }
382
+ ]
379
383
  }
380
384
  }
381
385
  ```
@@ -383,6 +387,20 @@ After the script finishes, parse the JSON output:
383
387
  1. **Output `data.answer` verbatim** as your response text — print it exactly as-is so the user sees the full content.
384
388
  2. **Extract and save** `data.thread_short_id` and `data.live_doc_short_id` — you MUST use these in the next call.
385
389
  3. **Optionally show** `data.live_doc_url` so the user can view the LiveDoc canvas in a browser.
390
+ 4. **Image results (`data.image_urls`):** If this array is non-empty, append image links immediately after `data.answer`, formatted as **one line per image**:
391
+
392
+ ```
393
+ [title](url)
394
+ ```
395
+
396
+ Example output:
397
+ ```
398
+ [Giant panda eating bamboo](https://...)
399
+ [Giant panda dancing](https://...)
400
+ [Blue whale leaping out of the water](https://...)
401
+ ```
402
+
403
+ Each image has `url` (signed S3 URL, time-limited), `title`, and `file_id` (stable file identifier). Note: the same image may appear in both `tools_result_stream` and `tools_result` events with different signed URLs — deduplication is handled automatically by `file_id`. When referencing a previously generated image in a follow-up query, include its `file_id` in the `--query` so SuperAgent can locate the file (e.g., `"Please generate a variation of file_id=b9e5be11-..."`).
386
404
 
387
405
  Do NOT show `thread_short_id` or `live_doc_short_id` to the user unless they ask for it.
388
406
 
@@ -717,8 +735,8 @@ User sends a message
717
735
  |
718
736
  v
719
737
  Have live_doc_id from ANY source?
720
- NO --> Step 2b: fetch list --> got items?
721
- YES --> use data.items[0].short_id as live_doc_id
738
+ NO --> Step 2b: fetch list --> got is_shared=false item?
739
+ YES --> use data.items.find(i => !i.is_shared)?.short_id as live_doc_id
722
740
  NO --> Step 2c: create new LiveDoc
723
741
  YES --> continue (reuse it, do NOT fetch list)
724
742
  |
@@ -8,5 +8,6 @@
8
8
  "license": "MIT",
9
9
  "pricing": "free",
10
10
  "support_url": "https://github.com/Felo-Inc/felo-skills/issues",
11
- "homepage": "https://github.com/Felo-Inc/felo-skills"
11
+ "homepage": "https://github.com/Felo-Inc/felo-skills",
12
+ "dependencies": ["felo-livedoc"]
12
13
  }
@@ -168,14 +168,14 @@ function extractToolResults(data) {
168
168
  if (!callResult) continue;
169
169
  if (Array.isArray(callResult)) {
170
170
  for (const item of callResult) {
171
- if (item?.image_url) out.push({ type: 'image', title: item?.title || '', image_url: item.image_url });
171
+ if (item?.image_url) out.push({ type: 'image', title: item?.title || '', image_url: item.image_url, file_id: item?.file_id || null });
172
172
  }
173
173
  } else if (callResult?.images && Array.isArray(callResult.images)) {
174
174
  for (const img of callResult.images) {
175
- if (img?.image_url) out.push({ type: 'image', title: img?.title || '', image_url: img.image_url });
175
+ if (img?.image_url) out.push({ type: 'image', title: img?.title || '', image_url: img.image_url, file_id: img?.file_id || null });
176
176
  }
177
177
  } else if (callResult?.image_url) {
178
- out.push({ type: 'image', title: callResult?.title || '', image_url: callResult.image_url });
178
+ out.push({ type: 'image', title: callResult?.title || '', image_url: callResult.image_url, file_id: callResult?.file_id || null });
179
179
  }
180
180
  }
181
181
  if (t?.name === 'generate_discovery' && callResult?.status === 'success') {
@@ -477,7 +477,9 @@ async function main() {
477
477
 
478
478
  const onToolResult = (item) => {
479
479
  const LIVEDOC_TYPES = new Set(['document', 'ppt', 'html', 'discovery']);
480
- const key = item?.image_url || (LIVEDOC_TYPES.has(item?.type) ? item.type : `${item?.type}:${item?.title}`);
480
+ const key = (item?.type === 'image' && item?.file_id)
481
+ ? `file:${item.file_id}`
482
+ : item?.image_url || (LIVEDOC_TYPES.has(item?.type) ? item.type : `${item?.type}:${item?.title}`);
481
483
  if (seenKeys.has(key)) return;
482
484
  seenKeys.add(key);
483
485
  toolResults.push(item);
@@ -543,7 +545,7 @@ async function main() {
543
545
  answer: answer || null,
544
546
  thread_short_id: thread_short_id ?? null,
545
547
  live_doc_short_id: live_doc_short_id ?? null,
546
- image_urls: images.length > 0 ? images.map((r) => ({ url: r.image_url, title: r.title })) : undefined,
548
+ image_urls: images.length > 0 ? images.map((r) => ({ url: r.image_url, title: r.title, ...(r.file_id ? { file_id: r.file_id } : {}) })) : undefined,
547
549
  discoveries: discoveries.length > 0 ? discoveries.map((r) => ({ title: r.title })) : undefined,
548
550
  documents: documents.length > 0 ? documents.map((r) => ({ title: r.title })) : undefined,
549
551
  ppts: ppts.length > 0 ? ppts.map((r) => ({ title: r.title })) : undefined,
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "Felo Twitter Writer",
3
+ "tagline": "Analyze tweet style DNA and compose tweets, threads, X posts with brand style in Claude Code",
4
+ "description": "Felo Twitter Writer lets you analyze any Twitter/X account's writing style and extract a Style DNA document, then compose high-quality tweets, threads, or X long-form posts that match that style. Supports style library, multi-language, and continuous follow-up. Requires a Felo API key.",
5
+ "category": "writing",
6
+ "tags": ["felo", "twitter", "tweet", "writing", "style", "thread", "ghostwrite"],
7
+ "version": "1.0.0",
8
+ "license": "MIT",
9
+ "pricing": "free",
10
+ "support_url": "https://github.com/Felo-Inc/felo-skills/issues",
11
+ "homepage": "https://github.com/Felo-Inc/felo-skills",
12
+ "dependencies": ["felo-superAgent", "felo-livedoc"]
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "felo-ai",
3
- "version": "0.2.50",
3
+ "version": "0.2.52",
4
4
  "description": "Felo AI CLI - real-time search, PPT generation, SuperAgent conversation, LiveDoc management, web fetch, YouTube subtitles, LiveDoc knowledge base, and X (Twitter) search from the terminal",
5
5
  "type": "module",
6
6
  "main": "src/cli.js",
package/src/cli.js CHANGED
@@ -4,6 +4,7 @@ import { createRequire } from "module";
4
4
  import { Command } from "commander";
5
5
  import { search } from "./search.js";
6
6
  import { slides, listPptThemes } from "./slides.js";
7
+ import { mindmap, listMindmapLayouts } from "./mindmap.js";
7
8
  import { superAgent, listLiveDocs, listLiveDocResources, listStyleLibrary } from "./superAgent.js";
8
9
  import { appleBuyAdvisor } from "./appleBuyAdvisor.js";
9
10
  import { webFetch } from "./webFetch.js";
@@ -137,6 +138,36 @@ program
137
138
  flushStdioThenExit(code);
138
139
  });
139
140
 
141
+ program
142
+ .command("mindmap")
143
+ .description("Generate a mindmap from a prompt (synchronous API)")
144
+ .argument("<query>", "mindmap topic or question")
145
+ .option("-l, --layout <type>", "layout type (default: MIND_MAP)")
146
+ .option("--livedoc-short-id <id>", "add to existing LiveDoc")
147
+ .option("-j, --json", "output raw JSON with resource_id and livedoc_short_id")
148
+ .option("-t, --timeout <seconds>", "request timeout in seconds", "60")
149
+ .action(async (query, opts) => {
150
+ const timeoutMs = parseInt(opts.timeout, 10) * 1000;
151
+ const code = await mindmap(query, {
152
+ layout: opts.layout,
153
+ livedocShortId: opts.livedocShortId,
154
+ json: opts.json,
155
+ timeoutMs: Number.isNaN(timeoutMs) ? 60000 : timeoutMs,
156
+ });
157
+ process.exitCode = code;
158
+ flushStdioThenExit(code);
159
+ });
160
+
161
+ program
162
+ .command("mindmap-layouts")
163
+ .description("List available mindmap layout types")
164
+ .option("-j, --json", "output raw JSON")
165
+ .action(async (opts) => {
166
+ const code = await listMindmapLayouts({ json: opts.json });
167
+ process.exitCode = code;
168
+ flushStdioThenExit(code);
169
+ });
170
+
140
171
  program
141
172
  .command("superagent")
142
173
  .description(
package/src/mindmap.js ADDED
@@ -0,0 +1,185 @@
1
+ import {
2
+ getApiKey,
3
+ fetchWithTimeoutAndRetry,
4
+ NO_KEY_MESSAGE,
5
+ } from "./search.js";
6
+
7
+ const DEFAULT_API_BASE = "https://openapi.felo.ai";
8
+ const DEFAULT_REQUEST_TIMEOUT_MS = 60_000;
9
+ const DEFAULT_LAYOUT = "MIND_MAP";
10
+
11
+ const VALID_LAYOUTS = [
12
+ "MIND_MAP",
13
+ "LOGICAL_STRUCTURE",
14
+ "ORGANIZATION_STRUCTURE",
15
+ "CATALOG_ORGANIZATION",
16
+ "TIMELINE",
17
+ "FISHBONE",
18
+ ];
19
+
20
+ /** API base URL (default https://openapi.felo.ai). Override via FELO_API_BASE env or config if needed. */
21
+ async function getApiBase() {
22
+ let base = process.env.FELO_API_BASE?.trim();
23
+ if (!base) {
24
+ const { getConfigValue } = await import("./config.js");
25
+ const v = await getConfigValue("FELO_API_BASE");
26
+ base = typeof v === "string" ? v.trim() : "";
27
+ }
28
+ const normalized = (base || DEFAULT_API_BASE).replace(/\/$/, "");
29
+ return normalized;
30
+ }
31
+
32
+ /**
33
+ * Create a mindmap. Returns { resource_id, status, mindmap_url, livedoc_short_id } or throws.
34
+ * Uses fetchWithTimeoutAndRetry for 5xx retry.
35
+ * @param {string} apiKey
36
+ * @param {string} query
37
+ * @param {string} layout
38
+ * @param {string} livedocShortId
39
+ * @param {number} timeoutMs
40
+ * @param {string} apiBase
41
+ */
42
+ async function createMindmap(apiKey, query, layout, livedocShortId, timeoutMs, apiBase) {
43
+ const url = `${apiBase}/v2/mindmap`;
44
+ const body = { query: query.trim(), layout };
45
+ if (livedocShortId) {
46
+ body.livedoc_short_id = livedocShortId;
47
+ }
48
+
49
+ const res = await fetchWithTimeoutAndRetry(
50
+ url,
51
+ {
52
+ method: "POST",
53
+ headers: {
54
+ Accept: "application/json",
55
+ Authorization: `Bearer ${apiKey}`,
56
+ "Content-Type": "application/json",
57
+ },
58
+ body: JSON.stringify(body),
59
+ },
60
+ timeoutMs
61
+ );
62
+
63
+ const data = await res.json().catch(() => ({}));
64
+
65
+ if (data.status === "error") {
66
+ const msg = data.message || data.code || "Unknown error";
67
+ throw new Error(msg);
68
+ }
69
+
70
+ if (!res.ok) {
71
+ const msg =
72
+ data.message || data.error || res.statusText || `HTTP ${res.status}`;
73
+ throw new Error(msg);
74
+ }
75
+
76
+ const payload = data.data;
77
+ if (!payload) {
78
+ throw new Error("Unexpected response: missing data");
79
+ }
80
+
81
+ return payload;
82
+ }
83
+
84
+ /**
85
+ * Run mindmap: create mindmap and output URL or error.
86
+ * @returns {Promise<number>} exit code (0 success, 1 failure)
87
+ */
88
+ export async function mindmap(query, options = {}) {
89
+ const apiKey = await getApiKey();
90
+ if (!apiKey) {
91
+ console.error(NO_KEY_MESSAGE.trim());
92
+ return 1;
93
+ }
94
+
95
+ const requestTimeoutMs = options.timeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
96
+ const layout = (options.layout || DEFAULT_LAYOUT).toUpperCase();
97
+
98
+ // Validate layout
99
+ if (!VALID_LAYOUTS.includes(layout)) {
100
+ console.error(`Error: Invalid layout "${options.layout}"`);
101
+ console.error("");
102
+ console.error("Available layouts:");
103
+ VALID_LAYOUTS.forEach((l) => console.error(` - ${l}`));
104
+ return 1;
105
+ }
106
+
107
+ try {
108
+ const apiBase = await getApiBase();
109
+
110
+ process.stderr.write("Creating mindmap...\n");
111
+
112
+ const result = await createMindmap(
113
+ apiKey,
114
+ query,
115
+ layout,
116
+ options.livedocShortId,
117
+ requestTimeoutMs,
118
+ apiBase
119
+ );
120
+
121
+ const mindmapUrl = result.mindmap_url;
122
+ const livedocShortId = result.livedoc_short_id;
123
+ const resourceId = result.resource_id;
124
+
125
+ if (options.json) {
126
+ console.log(
127
+ JSON.stringify(
128
+ {
129
+ status: "ok",
130
+ data: {
131
+ resource_id: resourceId,
132
+ mindmap_status: result.status,
133
+ mindmap_url: mindmapUrl,
134
+ livedoc_short_id: livedocShortId,
135
+ message: result.message,
136
+ },
137
+ },
138
+ null,
139
+ 2
140
+ )
141
+ );
142
+ } else {
143
+ if (mindmapUrl) {
144
+ process.stderr.write("Mindmap ready. Open this link to view:\n");
145
+ console.log(mindmapUrl);
146
+ } else {
147
+ console.error("Error: No mindmap_url in response");
148
+ return 1;
149
+ }
150
+ }
151
+
152
+ return 0;
153
+ } catch (err) {
154
+ console.error("Error:", err.message || err);
155
+ return 1;
156
+ }
157
+ }
158
+
159
+ /**
160
+ * List available layout types for mindmap.
161
+ * @returns {Promise<number>} exit code (0 success)
162
+ */
163
+ export async function listMindmapLayouts(options = {}) {
164
+ if (options.json) {
165
+ console.log(JSON.stringify({ layouts: VALID_LAYOUTS }, null, 2));
166
+ return 0;
167
+ }
168
+
169
+ console.log("Available mindmap layouts:\n");
170
+ const layoutDescriptions = {
171
+ MIND_MAP: "Classic mind map (default)",
172
+ LOGICAL_STRUCTURE: "Logical structure diagram",
173
+ ORGANIZATION_STRUCTURE: "Organization chart",
174
+ CATALOG_ORGANIZATION: "Catalog organization chart",
175
+ TIMELINE: "Timeline diagram",
176
+ FISHBONE: "Fishbone diagram",
177
+ };
178
+
179
+ for (const l of VALID_LAYOUTS) {
180
+ const desc = layoutDescriptions[l] || "";
181
+ console.log(` ${l.padEnd(22)} ${desc}`);
182
+ }
183
+
184
+ return 0;
185
+ }