felo-ai 0.2.50 → 0.2.51

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
@@ -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
 
@@ -296,6 +307,7 @@ For skill-based new conversations, Claude fetches the matching style library, pr
296
307
  # Via ClawHub (recommended)
297
308
  clawhub install felo-search
298
309
  clawhub install felo-slides
310
+ clawhub install felo-mindmap
299
311
  clawhub install felo-web-fetch
300
312
  clawhub install felo-youtube-subtitling
301
313
  clawhub install felo-x-search
@@ -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();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "felo-ai",
3
- "version": "0.2.50",
3
+ "version": "0.2.51",
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
+ }