methodalgo-cli 1.0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Justin
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.
package/README.md ADDED
@@ -0,0 +1,276 @@
1
+
2
+
3
+ # ๐Ÿš€ Methodalgo CLI
4
+
5
+ [English](#english) | [ไธญๆ–‡](#ไธญๆ–‡)
6
+ ```text
7
+ โ–„โ–„โ–„ โ–„โ–„โ–„ โ–„โ–„ โ–„โ–„ โ–„โ–„โ–„โ–„ โ–„โ–„
8
+ โ–ˆโ–ˆโ–ˆโ–ˆโ–„ โ–„โ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆ โ–ˆโ–ˆ โ–ˆโ–ˆ โ–„โ–ˆโ–ˆโ–€โ–€โ–ˆโ–ˆโ–„ โ–ˆโ–ˆ
9
+ โ–ˆโ–ˆโ–ˆโ–€โ–ˆโ–ˆโ–ˆโ–ˆโ–€โ–ˆโ–ˆโ–ˆ โ–„โ–ˆโ–€โ–ˆโ–„ โ–€โ–ˆโ–ˆโ–€โ–€ โ–ˆโ–ˆโ–ˆโ–ˆโ–„ โ–„โ–ˆโ–ˆโ–ˆโ–„ โ–„โ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆ โ–„โ–ˆโ–ˆโ–ˆโ–ˆ โ–„โ–ˆโ–ˆโ–ˆโ–„
10
+ โ–ˆโ–ˆโ–ˆ โ–€โ–€ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–„โ–ˆโ–€ โ–ˆโ–ˆ โ–ˆโ–ˆ โ–ˆโ–ˆ โ–ˆโ–ˆ โ–ˆโ–ˆ โ–ˆโ–ˆ โ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–€โ–€โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆ โ–ˆโ–ˆ โ–ˆโ–ˆ โ–ˆโ–ˆ โ–ˆโ–ˆ
11
+ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–€โ–ˆโ–„โ–„โ–„ โ–ˆโ–ˆ โ–ˆโ–ˆ โ–ˆโ–ˆ โ–€โ–ˆโ–ˆโ–ˆโ–€ โ–€โ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆ โ–€โ–ˆโ–ˆโ–ˆโ–ˆ โ–€โ–ˆโ–ˆโ–ˆโ–€
12
+ โ–ˆโ–ˆ
13
+ โ–€โ–€โ–€
14
+ ```
15
+ ---
16
+
17
+ <a name="english"></a>
18
+ ## English
19
+
20
+ [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](https://opensource.org/licenses/ISC)
21
+ ![Node Version](https://img.shields.io/badge/node-%3E%3D20.0.0-green.svg)
22
+
23
+ ### Overview
24
+ `methodalgo-cli` is an ultra-fast, professional L2 signals & tools terminal based on Node.js. Specially designed for traders and AI agents, it allows users to quickly obtain cryptocurrency market snapshots, news, and signals with deep optimization for LLM workflows.
25
+
26
+ ### ๐Ÿš€ Highlights
27
+
28
+ - โšก **Lightning Fast**: Built on Node SEA, millisecond startup time.
29
+ - ๐Ÿ–ผ๏ธ **Terminal Rendering**: Deeply compatible with iTerm2 for previewing snapshots in-terminal.
30
+ - ๐ŸŒ **Multi-language**: Native support for Chinese and English.
31
+ - ๐Ÿค– **AI Friendly**: Clean JSON output, perfect for AI Agent integration.
32
+
33
+ ---
34
+
35
+ ### ๐Ÿ› ๏ธ Installation
36
+
37
+ #### ๐ŸŒŸ Recommended: NPM Global Install
38
+ This is the fastest and easiest way to upgrade. Ensure [Node.js](https://nodejs.org/) (v20+) is installed on your system:
39
+ ```bash
40
+ npm install -g methodalgo-cli
41
+ ```
42
+
43
+ #### ๐Ÿ“ฆ Other Installation Methods
44
+
45
+ **1. Standalone Binary (No Node.js Required)**
46
+ Download the binary for your platform from [Releases](https://github.com/methodalgo/methodalgo-cli/releases). To make it globally accessible:
47
+ - **macOS / Linux**: Move the binary to `/usr/local/bin` and rename it to `methodalgo`:
48
+ ```bash
49
+ sudo mv methodalgo-macos-arm64 /usr/local/bin/methodalgo
50
+ sudo chmod +x /usr/local/bin/methodalgo
51
+ ```
52
+ - **Windows**: Add the folder containing `methodalgo-win-x64.exe` to your [System Environment Variables](https://www.google.com/search?q=how+to+add+to+path+windows).
53
+
54
+ **2. Install from Source**
55
+ ```bash
56
+ git clone https://github.com/methodalgo/methodalgo-cli.git
57
+ cd methodalgo-cli
58
+ npm install
59
+ npm link # Link local command
60
+ ```
61
+
62
+ ---
63
+ #### ๐Ÿ–ฅ๏ธ Market Dashboard (`dashboard`)
64
+ Launch a real-time TUI (Terminal User Interface) dashboard for a global view of market insights, news, and signals.
65
+
66
+ ![Dashboard Preview](./screenshot/dashboard.png)
67
+
68
+ * **Usage**: `methodalgo dashboard` (Alias: `top`)
69
+ * **Controls**: Use `TAB` to switch panels, `UP/DOWN` to scroll, and `ENTER` to view details.
70
+
71
+ **Example**: `methodalgo dashboard`
72
+
73
+ ---
74
+
75
+ ### โš™๏ธ Commands
76
+
77
+ #### ๐Ÿ“ธ Market Snapshot (`snapshot`)
78
+ Get a real-time TradingView chart snapshot for a specific symbol.
79
+
80
+ * **Usage**: `methodalgo snapshot <symbol> [options]`
81
+ * **Options**:
82
+ * `-t, --tf <timeframe>`: Timeframe (e.g., 1, 15, 60, 4h, D) (Default: "60")
83
+ * `--json`: Output WebP image URL in JSON format.
84
+ * `--url`: Force URL output only (do not attempt terminal rendering).
85
+
86
+ **Example**: `methodalgo snapshot BTCUSDT --json`
87
+
88
+ **๐Ÿ’ก Response Preview**
89
+ - **Standard Mode (iTerm2)**: High-definition WebP chart rendered directly in terminal.
90
+ - **JSON Mode**:
91
+ ```json
92
+ {
93
+ "url": "https://m.methodalgo.com/tmp/1774563764359.webp"
94
+ }
95
+ ```
96
+
97
+ #### ๐Ÿ“ก Trading Signals (`signals`)
98
+ Fetch the latest Alpha signals or market indices from specified channels.
99
+
100
+ * **Usage**: `methodalgo signals [channel] [options]`
101
+ * **Popular Channels**:
102
+ * `etf-tracker`: Real-time daily inflow/outflow details for BTC/ETH ETFs.
103
+ * `market-today`: Daily market summary (Fear & Greed Index, Altcoin Season Index, etc.).
104
+ * `golden-pit-mtf`: High-quality low-frequency pattern recognition signals.
105
+ * **Options**:
106
+ * `-l, --limit <number>`: Number of signals to fetch (Default: "10")
107
+ * `--json`: Output raw signals array in JSON format.
108
+
109
+ **Example**: `methodalgo signals etf-tracker --limit 1`
110
+
111
+ **๐Ÿ’ก Response Preview**
112
+ - **List Mode**:
113
+ ```text
114
+ [Index] Title | Content Summary (Publish Time)
115
+ > Detailed data (e.g., ETF net inflow)
116
+ Original: [URL]
117
+ ```
118
+
119
+ #### ๐Ÿ“ฐ Market News (`news`)
120
+ Get multi-language crypto market news filtered by AI.
121
+
122
+ * **Usage**: `methodalgo news [options]`
123
+ * **News Types**: `breaking`, `article`, `onchain`, `report`
124
+ * **Options**:
125
+ * `-t, --type <type>`: News category (Default: "breaking")
126
+ * `-l, --limit <number>`: Result count (Default: "10")
127
+ * `-g, --language <lang>`: Output language (zh/en) (Default: "zh")
128
+ * `-s, --search <keyword>`: Search keyword in titles.
129
+
130
+ **Example**: `methodalgo news --type breaking --limit 1 --json`
131
+
132
+ **๐Ÿ’ก Response Preview**
133
+ ```json
134
+ [
135
+ {
136
+ "type": "news",
137
+ "title": { "zh": "็ชๅ‘๏ผš...", "en": "JUST IN: ..." },
138
+ "publish_date": "2026-03-26T22:03:49+00:00",
139
+ "url": "https://..."
140
+ }
141
+ ]
142
+ ```
143
+
144
+
145
+ ---
146
+
147
+ <a name="ไธญๆ–‡"></a>
148
+ ## ไธญๆ–‡
149
+
150
+ [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](https://opensource.org/licenses/ISC)
151
+ ![Node Version](https://img.shields.io/badge/node-%3E%3D20.0.0-green.svg)
152
+
153
+ ### ้กน็›ฎๆฆ‚่งˆ
154
+ `methodalgo-cli` ๆ˜ฏไธ€ไธชๅŸบไบŽ Node.js ๅผ€ๅ‘็š„ๆž้€Ÿใ€ไธ“ไธš็š„ๅŠ ๅฏ†่ดงๅธๅธ‚ๅœบ L2 ไฟกๅทไธŽๅทฅๅ…ท็ปˆ็ซฏใ€‚ๅฎƒไธ“ไธบไบคๆ˜“่€…ไธŽ AI ไปฃ็†่ฎพ่ฎก๏ผŒ้›†ๆˆไบ†ๅธ‚ๅœบๅฟซ็…งใ€ๆ–ฐ้—ปไธŽไฟกๅทๆŠ“ๅ–๏ผŒๅนถ้’ˆๅฏน LLM ๅทฅไฝœๆต่ฟ›่กŒไบ†ๆทฑๅบฆไผ˜ๅŒ–ใ€‚
155
+
156
+ ### ๐Ÿ–ฅ๏ธ ๅŠŸ่ƒฝไบฎ็‚น
157
+
158
+ - โšก **ๆž่‡ด้€Ÿๅบฆ**: ๅŸบไบŽ Node SEA ๆ‰“้€ ๏ผŒๅฏๅŠจๆฏซ็ง’็บงใ€‚
159
+ - ๐Ÿ–ผ๏ธ **็ปˆ็ซฏ็ป˜ๅ›พ**: ๆทฑๅบฆ้€‚้… iTerm2๏ผŒๆ— ้œ€็ฆปๅผ€็ปˆ็ซฏๅณๅฏ้ข„่งˆๆˆชๅ›พใ€‚
160
+ - ๐ŸŒ **ๅคš่ฏญ่จ€**: ๅŽŸ็”Ÿๆ”ฏๆŒไธญ่‹ฑๅŒ่ฏญๅˆ‡ๆขใ€‚
161
+ - ๐Ÿค– **LLM ๅ‹ๅฅฝ**: ๆไพ›็ป“ๆž„ๆธ…ๆ™ฐ็š„ JSON ่พ“ๅ‡บ๏ผŒๅฎŒ็พŽ้€‚้… AI Agent ้›†ๆˆใ€‚
162
+
163
+ ---
164
+
165
+ ### ๐Ÿ› ๏ธ ๅฎ‰่ฃ…ๆŒ‡ๅ—
166
+
167
+ #### ๐ŸŒŸ ๆŽจ่ๆ–นๅผ๏ผšNPM ๅ…จๅฑ€ๅฎ‰่ฃ…
168
+ ่ฟ™ๆ˜ฏๆœ€ๅฟซ้€Ÿใ€ๆœ€ๆ˜“ไบŽๅ‡็บง็š„ๆ–นๅผใ€‚็กฎไฟๆ‚จ็š„็ณป็ปŸๅทฒๅฎ‰่ฃ… [Node.js](https://nodejs.org/) (v20+):
169
+ ```bash
170
+ npm install -g methodalgo-cli
171
+ ```
172
+
173
+ #### ๐Ÿ“ฆ ๅ…ถไป–ๅฎ‰่ฃ…ๆ–นๅผ
174
+
175
+ **1. ็‹ฌ็ซ‹ไบŒ่ฟ›ๅˆถ็‰ˆ (ๆ— ้œ€ Node.js)**
176
+ ไปŽ [Releases](https://github.com/methodalgo/methodalgo-cli/releases) ไธ‹่ฝฝๅฏนๅบ”ๅนณๅฐ็š„ไบŒ่ฟ›ๅˆถๆ–‡ไปถใ€‚ไธบไบ†ๅ…จๅฑ€่ฐƒ็”จ๏ผŒๅปบ่ฎฎ๏ผš
177
+ - **macOS / Linux**: ๅฐ†ๆ–‡ไปถ็งปๅŠจๅˆฐ `/usr/local/bin` ๅนถ้‡ๅ‘ฝๅไธบ `methodalgo`:
178
+ ```bash
179
+ sudo mv methodalgo-macos-arm64 /usr/local/bin/methodalgo
180
+ sudo chmod +x /usr/local/bin/methodalgo
181
+ ```
182
+ - **Windows**: ๅฐ†ๅŒ…ๅซ `methodalgo-win-x64.exe` ็š„ๆ–‡ไปถๅคน่ทฏๅพ„ๆทปๅŠ ๅˆฐ็ณป็ปŸ็š„ [็Žฏๅขƒๅ˜้‡ PATH](https://www.baidu.com/s?wd=%E5%A6%82%E4%BD%95%E5%B0%86%E6%96%87%E4%BB%B6%E5%A4%B9%E6%B7%BB%E5%8A%A0%E5%88%B0PATH) ไธญใ€‚
183
+
184
+ **2. ๅผ€ๅ‘ๆบ็ ๅฎ‰่ฃ…**
185
+ ```bash
186
+ git clone https://github.com/methodalgo/methodalgo-cli.git
187
+ cd methodalgo-cli
188
+ npm install
189
+ npm link # ้“พๆŽฅๆœฌๅœฐๆŒ‡ไปค
190
+ ```
191
+
192
+ ---
193
+
194
+ #### ๐Ÿ–ฅ๏ธ ๅธ‚ๅœบ็œ‹ๆฟ (`dashboard`)
195
+ ๅฏๅŠจๅฎžๆ—ถ TUI๏ผˆ็ปˆ็ซฏ็”จๆˆท็•Œ้ข๏ผ‰ไปช่กจ็›˜๏ผŒๅ…จๅฑ€ไฟฏ็žฐๅธ‚ๅœบๆดžๅฏŸใ€ๆ–ฐ้—ปไธŽไฟกๅทใ€‚
196
+
197
+ ![Dashboard Preview](./screenshot/dashboard.png)
198
+
199
+ * **็”จๆณ•**: `methodalgo dashboard` (ๅˆซๅ: `top`)
200
+ * **ๆ“ไฝœ**: ไฝฟ็”จ `TAB` ๅˆ‡ๆข้ขๆฟ๏ผŒ`UP/DOWN` ๆปšๅŠจๅˆ—่กจ๏ผŒ`ENTER` ๅผนๅ‡บ่ฏฆๆƒ…ใ€‚
201
+
202
+ **็คบไพ‹**: `methodalgo dashboard`
203
+
204
+ ---
205
+
206
+ ### โš™๏ธ ๆŒ‡ไปคๆŒ‡ๅ—
207
+
208
+ #### ๐Ÿ“ธ ๅธ‚ๅœบๅฟซ็…ง (`snapshot`)
209
+ ่Žทๅ–ๆŒ‡ๅฎšไบคๆ˜“ๅฏน็š„ๅฎžๆ—ถ TradingView ๅ›พ่กจๅฟซ็…งใ€‚
210
+
211
+ * **็”จๆณ•**: `methodalgo snapshot <symbol> [options]`
212
+ * **้€‰้กน**:
213
+ * `-t, --tf <timeframe>`: ๆ—ถ้—ดๅ‘จๆœŸ (ๅฆ‚: 1, 15, 60, 4h, D) (้ป˜่ฎค: "60")
214
+ * `--json`: ไปฅ JSON ๆ ผๅผ่พ“ๅ‡บ WebP ๅ›พ็‰‡ URLใ€‚
215
+ * `--url`: ๅผบๅˆถไป…่พ“ๅ‡บ URL๏ผˆไธๅฐ่ฏ•ๅœจ็ปˆ็ซฏๆธฒๆŸ“ๅ›พ็‰‡๏ผ‰ใ€‚
216
+
217
+ **็คบไพ‹**: `methodalgo snapshot BTCUSDT --json`
218
+
219
+ **๐Ÿ’ก ๅ“ๅบ”้ข„่งˆ**
220
+ - **ๆ ‡ๅ‡†ๆจกๅผ (iTerm2)**: ็›ดๆŽฅๅœจ็ปˆ็ซฏๆ˜พ็คบ้ซ˜ๆธ… WebP ๅ›พ่กจใ€‚
221
+ - **JSON ๆจกๅผ**:
222
+ ```json
223
+ {
224
+ "url": "https://m.methodalgo.com/tmp/1774563764359.webp"
225
+ }
226
+ ```
227
+
228
+ #### ๐Ÿ“ก ไบคๆ˜“ไฟกๅท (`signals`)
229
+ ไปŽๆŒ‡ๅฎš้ข‘้“่Žทๅ–ๆœ€ๆ–ฐ็š„ Alpha ไฟกๅทๆˆ–ๅธ‚ๅœบๆŒ‡ๆ ‡ใ€‚
230
+
231
+ * **็”จๆณ•**: `methodalgo signals [channel] [options]`
232
+ * **็ƒญ้—จ้ข‘้“**:
233
+ * `etf-tracker`: ็›‘ๆŽง BTC/ETH ETF ๆฏๆ—ฅๅฎžๆ—ถ่ต„้‡‘ๆตๅ…ฅ/ๆตๅ‡บ่ฏฆๆƒ…ใ€‚
234
+ * `market-today`: ๆฏๆ—ฅๅธ‚ๅœบๅ…จๆ™ฏๆ€ป็ป“๏ผˆๅŒ…ๅซๆๆƒง่ดชๅฉชๆŒ‡ๆ•ฐใ€ๅฑฑๅฏจๅญฃๆŒ‡ๆ•ฐ็ญ‰๏ผ‰ใ€‚
235
+ * `golden-pit-mtf`: ไฝŽ้ข‘้ซ˜่ดจ้‡ๆจกๅผ่ฏ†ๅˆซไฟกๅทใ€‚
236
+ * **้€‰้กน**:
237
+ * `-l, --limit <number>`: ่Žทๅ–ไฟกๅท็š„ๆ•ฐ้‡ (้ป˜่ฎค: "10")
238
+ * `--json`: ไปฅ JSON ๆ ผๅผ่พ“ๅ‡บๅŽŸๅง‹ไฟกๅทๆ•ฐ็ป„ใ€‚
239
+
240
+ **็คบไพ‹**: `methodalgo signals etf-tracker --limit 1`
241
+
242
+ **๐Ÿ’ก ๅ“ๅบ”้ข„่งˆ**
243
+ - **ๆ ‡ๅ‡†ๆจกๅผ**:
244
+ ```text
245
+ [ๅบๅท] ๆ ‡้ข˜ | ๆ ธๅฟƒๅ†…ๅฎนๆ‘˜่ฆ (ๅ‘ๅธƒๆ—ถ้—ด)
246
+ > ่ฏฆ็ป†ๆ•ฐๆฎ่ฏฆๆƒ… (ๅฆ‚ ETF ๅ‡€ๆตๅ…ฅ้ข)
247
+ ๆŸฅ็œ‹ๅŽŸๆ–‡: [URL]
248
+ ```
249
+
250
+ #### ๐Ÿ“ฐ ๅธ‚ๅœบๆ–ฐ้—ป (`news`)
251
+ ่Žทๅ–็ป่ฟ‡ AI ๅˆ†้€‰็š„ๅคš่ฏญ่จ€ๅŠ ๅฏ†่ดงๅธๅธ‚ๅœบๆ–ฐ้—ปใ€‚
252
+
253
+ * **็”จๆณ•**: `methodalgo news [options]`
254
+ * **ๆ–ฐ้—ป็ฑปๅž‹**: `breaking` (ๅฟซ่ฎฏ), `article` (ๆทฑๅบฆ), `onchain` (้“พไธŠ), `report` (ๆŠฅๅ‘Š)
255
+ * **้€‰้กน**:
256
+ * `-t, --type <type>`: ๆ–ฐ้—ปๅˆ†็ฑป (้ป˜่ฎค: "breaking")
257
+ * `-l, --limit <number>`: ็ป“ๆžœๆ•ฐ้‡ (้ป˜่ฎค: "10")
258
+ * `-g, --language <lang>`: ่พ“ๅ‡บ่ฏญ่จ€ (zh/en) (้ป˜่ฎค: "zh")
259
+ * `-s, --search <keyword>`: ๆ ‡้ข˜ๅ…ณ้”ฎ่ฏๆœ็ดขใ€‚
260
+
261
+ **็คบไพ‹**: `methodalgo news --type breaking --limit 1 --json`
262
+
263
+ **๐Ÿ’ก ๅ“ๅบ”้ข„่งˆ**
264
+ ```json
265
+ [
266
+ {
267
+ "type": "news",
268
+ "title": { "zh": "็ชๅ‘๏ผš...", "en": "JUST IN: ..." },
269
+ "publish_date": "2026-03-26T22:03:49+00:00",
270
+ "url": "https://..."
271
+ }
272
+ ]
273
+ ```
274
+ ---
275
+
276
+ *Powered by Methodalgo.*
package/bin/index.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import "../src/index.js";
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "methodalgo-cli",
3
+ "version": "1.0.1",
4
+ "type": "module",
5
+ "main": "index.js",
6
+ "directories": {
7
+ "doc": "docs"
8
+ },
9
+ "scripts": {
10
+ "test": "echo \"Error: no test specified\" && exit 1",
11
+ "build": "node scripts/build-binary.js",
12
+ "release": "./scripts/release.sh"
13
+ },
14
+ "keywords": [],
15
+ "author": "",
16
+ "license": "ISC",
17
+ "description": "",
18
+ "bin": {
19
+ "methodalgo": "./bin/index.js"
20
+ },
21
+ "files": [
22
+ "bin/",
23
+ "src/",
24
+ "package.json",
25
+ "README.md",
26
+ "LICENSE"
27
+ ],
28
+ "preferGlobal": true,
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/methodalgo/methodalgo-cli.git"
32
+ },
33
+ "dependencies": {
34
+ "axios": "^1.13.6",
35
+ "chalk": "^4.1.2",
36
+ "commander": "^14.0.3",
37
+ "conf": "^15.1.0",
38
+ "ink": "^6.8.0",
39
+ "react": "^19.2.4",
40
+ "yoga-layout": "^3.2.1"
41
+ },
42
+ "devDependencies": {
43
+ "@babel/core": "^7.29.0",
44
+ "@babel/node": "^7.29.0",
45
+ "@babel/preset-env": "^7.29.2",
46
+ "@babel/preset-react": "^7.28.5",
47
+ "@rollup/plugin-commonjs": "^29.0.2",
48
+ "@rollup/plugin-json": "^6.1.0",
49
+ "@rollup/plugin-node-resolve": "^16.0.3",
50
+ "@rollup/plugin-terser": "^1.0.0",
51
+ "esbuild": "^0.27.4",
52
+ "postject": "^1.0.0-alpha.6",
53
+ "react-devtools-core": "^7.0.1",
54
+ "rollup": "^4.60.0"
55
+ }
56
+ }
@@ -0,0 +1,80 @@
1
+ import { Command } from "commander";
2
+ import chalk from "chalk";
3
+ import config from "../utils/config-manager.js";
4
+ import logger from "../utils/logger.js";
5
+ import { t } from "../utils/i18n.js";
6
+ import { validateApiKey } from "../utils/api.js";
7
+
8
+ const API_KEY_MAP = {
9
+ "api-key": "apiKey",
10
+ "lang": "lang",
11
+ "api-base": "apiBase"
12
+ };
13
+
14
+ const configCmd = new Command("config")
15
+ .description(t("CONFIG_DESC"))
16
+ .addHelpText("after", `\n${t("LABEL_EXAMPLE")}\n $ ${t("CONFIG_EXAMPLE")}\n`);
17
+
18
+ configCmd.addHelpText("after", `\n${t("VAL_ALLOWED_KEYS")}`);
19
+
20
+ configCmd
21
+ .command("set")
22
+ .description(t("CONFIG_SET_DESC"))
23
+ .argument("<key>", "Key (api-key, lang, api-base)")
24
+ .argument("<value>", "Value")
25
+ .action(async (key, value) => {
26
+ if (!API_KEY_MAP[key]) {
27
+ logger.error(t("ERR_INVALID_CONFIG_KEY", { key }));
28
+ console.log(chalk.yellow(`๐Ÿ’ก ${t("VAL_ALLOWED_KEYS")}`));
29
+ return;
30
+ }
31
+
32
+ const configKey = API_KEY_MAP[key];
33
+
34
+ // ๅ…ณ้”ฎๆ ก้ชŒ๏ผšๅฆ‚ๆžœๆ˜ฏ่ฎพ็ฝฎ API Key๏ผŒๅฟ…้กปๅ…ˆ้ชŒ่ฏๆœ‰ๆ•ˆๆ€ง
35
+ if (configKey === "apiKey") {
36
+ logger.info(`${t("ONBOARD_VALIDATING")}...`);
37
+ const isValid = await validateApiKey(value);
38
+ if (!isValid) {
39
+ logger.error(t("ONBOARD_FAILED"));
40
+ console.log(chalk.yellow(`๐Ÿ”— ${t("ONBOARD_GET_LINK")}`));
41
+ return;
42
+ }
43
+ logger.success(t("ONBOARD_SUCCESS"));
44
+ }
45
+
46
+ config.set(configKey, value);
47
+ logger.success(t("SET_SUCCESS", { key, value }));
48
+ });
49
+
50
+ configCmd
51
+ .command("get")
52
+ .description(t("CONFIG_GET_DESC"))
53
+ .argument("<key>", "Key (api-key, lang, api-base)")
54
+ .action((key) => {
55
+ if (!API_KEY_MAP[key]) {
56
+ logger.error(t("ERR_INVALID_CONFIG_KEY", { key }));
57
+ console.log(chalk.yellow(`๐Ÿ’ก ${t("VAL_ALLOWED_KEYS")}`));
58
+ return;
59
+ }
60
+
61
+ const configKey = API_KEY_MAP[key];
62
+ const value = config.get(configKey);
63
+ if (value) {
64
+ console.log(value);
65
+ } else {
66
+ logger.warn(t("VAL_NOT_SET", { key }));
67
+ }
68
+ });
69
+
70
+ configCmd
71
+ .command("list")
72
+ .description(t("CONFIG_LIST_DESC"))
73
+ .action(() => {
74
+ const all = config.store;
75
+ const safeData = { ...all };
76
+ if (safeData.apiKey) safeData.apiKey = "********";
77
+ logger.json(safeData);
78
+ });
79
+
80
+ export default configCmd;