bailian-cli 0.1.2 → 1.0.0

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,207 @@
1
+ # `bl video` commands
2
+
3
+ > Auto-generated from `packages/cli/src/commands/catalog.ts`. Do not edit by hand.
4
+ > Regenerate: `pnpm --filter bailian-cli run generate:reference` (runs automatically on `build`).
5
+
6
+ Index: [index.md](index.md)
7
+
8
+ ## Commands in this group
9
+
10
+ | Command | Description |
11
+ | --- | --- |
12
+ | `bl video download` | Download a completed video by task ID |
13
+ | `bl video edit` | Edit a video with happyhorse-1.0-video-edit (style transfer, object replacement, etc.) |
14
+ | `bl video generate` | Generate a video from text or image (happyhorse-1.0-t2v / happyhorse-1.0-i2v / wan2.6-t2v) |
15
+ | `bl video ref` | Reference-to-video generation (happyhorse-1.0-r2v / wan2.6-r2v): multi-subject, multi-shot with voice |
16
+ | `bl video task get` | Query async task status |
17
+
18
+ ## Command details
19
+
20
+ ### `bl video download`
21
+
22
+ | Field | Value |
23
+ | --- | --- |
24
+ | **Name** | `video download` |
25
+ | **Description** | Download a completed video by task ID |
26
+ | **Usage** | `bl video download --task-id <id> --out <path>` |
27
+
28
+ #### Options
29
+
30
+ | Flag | Type | Required | Description |
31
+ | --- | --- | --- | --- |
32
+ | `--task-id <id>` | string | no | Task ID to download from |
33
+ | `--out <path>` | string | no | Output file path |
34
+
35
+ #### Examples
36
+
37
+ ```bash
38
+ bl video download --task-id 3b256896-xxxx --out video.mp4
39
+ ```
40
+
41
+ ```bash
42
+ bl video download --task-id 3b256896-xxxx --out video.mp4 --quiet
43
+ ```
44
+
45
+ ### `bl video edit`
46
+
47
+ | Field | Value |
48
+ | --- | --- |
49
+ | **Name** | `video edit` |
50
+ | **Description** | Edit a video with happyhorse-1.0-video-edit (style transfer, object replacement, etc.) |
51
+ | **Usage** | `bl video edit --video <url> --prompt <text> [flags]` |
52
+ | **API docs** | [/best-practice/wanx/video-edit](https://help.aliyun.com/zh/model-studio/best-practice/wanx/video-edit) |
53
+
54
+ #### Options
55
+
56
+ | Flag | Type | Required | Description |
57
+ | --- | --- | --- | --- |
58
+ | `--model <model>` | string | no | Model ID (default: happyhorse-1.0-video-edit) |
59
+ | `--video <url>` | string | yes | Input video URL or local file (mp4/mov, 2-10s) |
60
+ | `--prompt <text>` | string | no | Edit instruction (e.g. "将画面转换为黏土风格") |
61
+ | `--ref-image <url>` | string | no | Reference image URL (up to 4, comma-separated) |
62
+ | `--negative-prompt <text>` | string | no | Negative prompt to exclude unwanted content |
63
+ | `--resolution <res>` | string | no | Resolution: 720P or 1080P (default: 1080P) |
64
+ | `--ratio <ratio>` | string | no | Aspect ratio (16:9, 9:16, 1:1, 4:3, 3:4) |
65
+ | `--duration <seconds>` | number | no | Output video duration in seconds (2-10) |
66
+ | `--audio-setting <mode>` | string | no | Audio: auto (default) or origin (keep original) |
67
+ | `--prompt-extend` | boolean | no | Enable prompt intelligent rewriting (default: true) |
68
+ | `--no-prompt-extend` | boolean | no | Disable prompt intelligent rewriting |
69
+ | `--watermark` | boolean | no | Add "AI生成" watermark |
70
+ | `--seed <n>` | number | no | Random seed for reproducible generation |
71
+ | `--download <path>` | string | no | Save video to file on completion |
72
+ | `--no-wait` | boolean | no | Return task ID immediately without waiting |
73
+ | `--async` | boolean | no | Return task ID immediately (agent/CI mode, same as --no-wait) |
74
+ | `--poll-interval <seconds>` | number | no | Polling interval when waiting (default: 15) |
75
+
76
+ #### Examples
77
+
78
+ ```bash
79
+ bl video edit --video https://example.com/input.mp4 --prompt "将整个画面转换为黏土风格"
80
+ ```
81
+
82
+ ```bash
83
+ bl video edit --video https://example.com/input.mp4 --prompt "替换衣服为图片中的款式" --ref-image https://example.com/clothes.png
84
+ ```
85
+
86
+ ```bash
87
+ bl video edit --video https://example.com/input.mp4 --prompt "Convert to anime style" --resolution 720P --download output.mp4
88
+ ```
89
+
90
+ ### `bl video generate`
91
+
92
+ | Field | Value |
93
+ | --- | --- |
94
+ | **Name** | `video generate` |
95
+ | **Description** | Generate a video from text or image (happyhorse-1.0-t2v / happyhorse-1.0-i2v / wan2.6-t2v) |
96
+ | **Usage** | `bl video generate --prompt <text> [--image <url>] [flags]` |
97
+ | **API docs** | [/best-practice/wanx/text-to-video](https://help.aliyun.com/zh/model-studio/best-practice/wanx/text-to-video) |
98
+
99
+ #### Options
100
+
101
+ | Flag | Type | Required | Description |
102
+ | --- | --- | --- | --- |
103
+ | `--model <model>` | string | no | Model ID (default: happyhorse-1.0-t2v, or happyhorse-1.0-i2v with --image) |
104
+ | `--prompt <text>` | string | yes | Video description |
105
+ | `--image <url>` | string | no | Input image URL for image-to-video generation |
106
+ | `--negative-prompt <text>` | string | no | Negative prompt to exclude unwanted content |
107
+ | `--resolution <res>` | string | no | Resolution (e.g. 1280*720, 960*960) |
108
+ | `--ratio <ratio>` | string | no | Aspect ratio (e.g. 16:9, 1:1) |
109
+ | `--duration <seconds>` | number | no | Video duration in seconds (default: 5) |
110
+ | `--prompt-extend` | boolean | no | Automatically extend prompt for better results |
111
+ | `--watermark` | boolean | no | Add watermark to generated video |
112
+ | `--seed <n>` | number | no | Random seed for reproducible generation |
113
+ | `--download <path>` | string | no | Save video to file on completion |
114
+ | `--no-wait` | boolean | no | Return task ID immediately without waiting |
115
+ | `--async` | boolean | no | Return task ID immediately (agent/CI mode, same as --no-wait) |
116
+ | `--poll-interval <seconds>` | number | no | Polling interval when waiting (default: 5) |
117
+
118
+ #### Examples
119
+
120
+ ```bash
121
+ bl video generate --prompt "一个人在读书,静态镜头"
122
+ ```
123
+
124
+ ```bash
125
+ bl video generate --prompt "Ocean waves at sunset." --download sunset.mp4
126
+ ```
127
+
128
+ ```bash
129
+ bl video generate --image https://example.com/cat.png --prompt "让画面中的猫动起来"
130
+ ```
131
+
132
+ ```bash
133
+ bl video generate --prompt "Mountain landscape" --resolution 1280*720 --duration 5
134
+ ```
135
+
136
+ ### `bl video ref`
137
+
138
+ | Field | Value |
139
+ | --- | --- |
140
+ | **Name** | `video ref` |
141
+ | **Description** | Reference-to-video generation (happyhorse-1.0-r2v / wan2.6-r2v): multi-subject, multi-shot with voice |
142
+ | **Usage** | `bl video ref --prompt <text> --image <url>... [--ref-video <url>...] [flags]` |
143
+ | **API docs** | [/best-practice/wanx/video-reference](https://help.aliyun.com/zh/model-studio/best-practice/wanx/video-reference) |
144
+
145
+ #### Options
146
+
147
+ | Flag | Type | Required | Description |
148
+ | --- | --- | --- | --- |
149
+ | `--model <model>` | string | no | Model ID (default: happyhorse-1.0-r2v) |
150
+ | `--prompt <text>` | string | yes | Video description with reference markers (图1, 视频1, etc.) |
151
+ | `--image <url>` | array | no | Reference image URL or local file (repeatable for multiple subjects) |
152
+ | `--ref-video <url>` | array | no | Reference video URL or local file (repeatable) |
153
+ | `--image-voice <url>` | array | no | Voice URL for corresponding image (pairs by position) |
154
+ | `--video-voice <url>` | array | no | Voice URL for corresponding ref-video (pairs by position) |
155
+ | `--resolution <res>` | string | no | Resolution: 720P or 1080P (default: 720P) |
156
+ | `--ratio <ratio>` | string | no | Aspect ratio (16:9, 9:16, 1:1) |
157
+ | `--duration <seconds>` | number | no | Video duration in seconds (2-10, default: 5) |
158
+ | `--prompt-extend` | boolean | no | Enable prompt intelligent rewriting |
159
+ | `--no-prompt-extend` | boolean | no | Disable prompt intelligent rewriting |
160
+ | `--watermark` | boolean | no | Add watermark to generated video |
161
+ | `--seed <n>` | number | no | Random seed for reproducible generation |
162
+ | `--download <path>` | string | no | Save video to file on completion |
163
+ | `--no-wait` | boolean | no | Return task ID immediately without waiting |
164
+ | `--async` | boolean | no | Return task ID immediately (agent/CI mode, same as --no-wait) |
165
+ | `--poll-interval <seconds>` | number | no | Polling interval when waiting (default: 15) |
166
+
167
+ #### Examples
168
+
169
+ ```bash
170
+ bl video ref --prompt "图1在草地上奔跑" --image person.jpg
171
+ ```
172
+
173
+ ```bash
174
+ bl video ref --prompt "视频1在弹吉他,图1走过来" --ref-video scene.mp4 --image person.jpg
175
+ ```
176
+
177
+ ```bash
178
+ bl video ref --prompt "图1说话" --image person.jpg --image-voice voice.mp3 --resolution 1080P
179
+ ```
180
+
181
+ ```bash
182
+ bl video ref --prompt "图1和图2在对话" --image a.jpg --image b.jpg --image-voice va.mp3 --image-voice vb.mp3
183
+ ```
184
+
185
+ ### `bl video task get`
186
+
187
+ | Field | Value |
188
+ | --- | --- |
189
+ | **Name** | `video task get` |
190
+ | **Description** | Query async task status |
191
+ | **Usage** | `bl video task get --task-id <id>` |
192
+
193
+ #### Options
194
+
195
+ | Flag | Type | Required | Description |
196
+ | --- | --- | --- | --- |
197
+ | `--task-id <id>` | string | no | Async task ID |
198
+
199
+ #### Examples
200
+
201
+ ```bash
202
+ bl video task get --task-id 3b256896-3e70-xxxx-xxxx-xxxxxxxxxxxx
203
+ ```
204
+
205
+ ```bash
206
+ bl video task get --task-id 3b256896-3e70-xxxx --output json
207
+ ```
@@ -0,0 +1,53 @@
1
+ # `bl vision` commands
2
+
3
+ > Auto-generated from `packages/cli/src/commands/catalog.ts`. Do not edit by hand.
4
+ > Regenerate: `pnpm --filter bailian-cli run generate:reference` (runs automatically on `build`).
5
+
6
+ Index: [index.md](index.md)
7
+
8
+ ## Commands in this group
9
+
10
+ | Command | Description |
11
+ | --- | --- |
12
+ | `bl vision describe` | Describe an image or video using Qwen-VL |
13
+
14
+ ## Command details
15
+
16
+ ### `bl vision describe`
17
+
18
+ | Field | Value |
19
+ | --- | --- |
20
+ | **Name** | `vision describe` |
21
+ | **Description** | Describe an image or video using Qwen-VL |
22
+ | **Usage** | `bl vision describe --image <path-or-url> [--video <url>] [--prompt <text>]` |
23
+
24
+ #### Options
25
+
26
+ | Flag | Type | Required | Description |
27
+ | --- | --- | --- | --- |
28
+ | `--image <path-or-url>` | string | no | Local image path or URL |
29
+ | `--video <url>` | array | no | Video file URL or local path (mp4/mov/avi/mkv/webm) |
30
+ | `--prompt <text>` | string | no | Question about the content (default: auto-detected) |
31
+ | `--model <model>` | string | no | Vision model (default: qwen-vl-max) |
32
+
33
+ #### Examples
34
+
35
+ ```bash
36
+ bl vision describe --image photo.jpg
37
+ ```
38
+
39
+ ```bash
40
+ bl vision describe --image https://example.com/photo.jpg --prompt "这只狗是什么品种?"
41
+ ```
42
+
43
+ ```bash
44
+ bl vision describe --video https://example.com/video.mp4 --prompt "总结视频内容"
45
+ ```
46
+
47
+ ```bash
48
+ bl vision describe --video ./local-video.mp4
49
+ ```
50
+
51
+ ```bash
52
+ bl vision describe --image photo.png --prompt "Extract the text" --model qwen-vl-plus
53
+ ```
package/README.md DELETED
@@ -1,291 +0,0 @@
1
- <div align="center">
2
-
3
- <img src="https://img.alicdn.com/imgextra/i1/O1CN01RSQFUD1jN5IBzHORt_!!6000000004535-2-tps-2440-521.png" alt="Bailian CLI" width="420" />
4
-
5
- # >_ Bailian CLI
6
-
7
- **The official command-line interface for Alibaba Cloud Bailian (DashScope) AI Platform**
8
-
9
- [![npm version](https://img.shields.io/npm/v/bailian-cli?color=0969da&label=npm)](https://www.npmjs.com/package/bailian-cli)
10
- [![Node.js](https://img.shields.io/badge/node-%3E%3D18-brightgreen)](https://nodejs.org)
11
- [![TypeScript](https://img.shields.io/badge/TypeScript-strict-3178c6)](https://www.typescriptlang.org)
12
- [![License](https://img.shields.io/badge/license-Apache%202.0-blue)](LICENSE)
13
-
14
- [中文文档](README_CN.md) · [API Documentation](https://help.aliyun.com/zh/model-studio/) · [Get API Key](https://bailian.console.aliyun.com/cn-beijing/?source_channel=aliway&tab=app#/api-key)
15
-
16
- ---
17
-
18
- *Chat with Qwen, generate images & videos, understand images, call agents,*
19
- *manage memory, search the web — all from your terminal.*
20
-
21
- *Built for AI Agents. Every command works as a structured tool call.*
22
-
23
- </div>
24
-
25
- ## Installation
26
-
27
- ```bash
28
- npm install -g bailian-cli
29
- ```
30
-
31
- After installation, both `bailian` and `bl` (short alias) are available.
32
-
33
- ## Quick Start
34
-
35
- ```bash
36
- # Authenticate
37
- bl auth login --api-key sk-xxxxx
38
-
39
- # Chat with Qwen
40
- bl text chat --message "What is DashScope?"
41
-
42
- # Multimodal chat (text + image + audio + video)
43
- bl omni --message "Describe this image" --image ./photo.jpg
44
-
45
- # Generate an image
46
- bl image generate --prompt "A cat in a spacesuit" --out-dir ./images/
47
-
48
- # Generate a video from local image
49
- bl video generate --image ./cat.png --prompt "Make the cat move" --download cat.mp4
50
- ```
51
-
52
- ## Features
53
-
54
- > **Local File Support**: All commands accepting file URLs also accept local file paths — files are auto-uploaded. Just pass `./photo.png` instead of a URL.
55
-
56
- <table>
57
- <tr><td>
58
-
59
- | Category | Commands | Default Model |
60
- |:---------|:---------|:--------------|
61
- | **Text** | `text chat` | qwen3.6-plus |
62
- | **Omni** | `omni` (text+image+audio+video) | qwen3.5-omni-plus |
63
- | **Image** | `image generate` | qwen-image-2.0 |
64
- | | `image edit` (multi-image merge) | qwen-image-2.0 |
65
- | **Video** | `video generate` (text/image-to-video) | happyhorse-1.0-t2v / happyhorse-1.0-i2v |
66
- | | `video edit` (style transfer) | happyhorse-1.0-video-edit |
67
- | | `video task get` / `video download` | — |
68
-
69
- </td></tr>
70
- <tr><td>
71
-
72
- | Category | Commands | Default Model |
73
- |:---------|:---------|:--------------|
74
- | **Vision** | `vision describe` | qwen-vl-max |
75
- | **Speech** | `speech synthesize` (TTS) | cosyvoice-v3-flash |
76
- | | `speech recognize` (ASR) | fun-asr |
77
- | **File** | `file upload` (to temp OSS) | — |
78
- | **App** | `app call` (agents / workflows) | — |
79
- | **Memory** | `memory add/search/list/update/delete` | — |
80
- | **Knowledge** | `knowledge retrieve` (RAG) | — |
81
- | **Search** | `search web` | — |
82
-
83
- </td></tr>
84
- </table>
85
-
86
- ## Usage Examples
87
-
88
- ### Text Chat
89
-
90
- ```bash
91
- # Simple chat
92
- bl text chat --message "Explain quantum computing"
93
-
94
- # Multi-turn conversation
95
- bl text chat --message "Hello" --message "assistant:Hi!" --message "How are you?"
96
-
97
- # With system prompt
98
- bl text chat --system "You are a coding assistant." --message "Write fizzbuzz in Python"
99
-
100
- # Enable thinking mode (qwen3 / qwq)
101
- bl text chat --model qwq-plus --message "Solve 1+1" --enable-thinking
102
- ```
103
-
104
- ### Omni Multimodal
105
-
106
- ```bash
107
- # Describe an image
108
- bl omni --message "What's in this photo?" --image ./photo.jpg
109
-
110
- # Understand audio
111
- bl omni --message "Transcribe this audio" --audio ./recording.wav
112
-
113
- # Generate speech output
114
- bl omni --message "Read this aloud" --audio-out greeting.wav
115
- ```
116
-
117
- ### Image Generation & Editing
118
-
119
- ```bash
120
- # Generate images
121
- bl image generate --prompt "Mountain landscape" --size 16:9
122
-
123
- # Generate multiple images
124
- bl image generate --prompt "Logo design" --n 3 --out-dir ./generated/
125
-
126
- # Edit an image (local file auto-uploaded)
127
- bl image edit --image ./photo.png --prompt "Change background to beach"
128
-
129
- # Multi-image merge
130
- bl image edit --image ./a.png --image ./b.png --prompt "Combine into a collage"
131
- ```
132
-
133
- ### Video Generation & Editing
134
-
135
- ```bash
136
- # Text to video
137
- bl video generate --prompt "A person reading a book" --download output.mp4
138
-
139
- # Image to video (local file auto-uploaded)
140
- bl video generate --image ./cat.png --prompt "Make the cat move" --ratio 3:4
141
-
142
- # Edit a video (style transfer)
143
- bl video edit --video ./input.mp4 --prompt "Convert to clay style"
144
- ```
145
-
146
- ### Speech
147
-
148
- ```bash
149
- # List available voices
150
- bl speech synthesize --list-voices --model cosyvoice-v3-flash
151
-
152
- # Text-to-speech
153
- bl speech synthesize --text "Hello world" --voice longyumi_v3 --out speech.wav
154
-
155
- # Stream to audio player (macOS)
156
- bl speech synthesize --text "你好" --voice longyumi_v3 --stream | afplay -
157
-
158
- # Speech-to-text (local file auto-uploaded)
159
- bl speech recognize --url ./meeting.mp3
160
- ```
161
-
162
- ### File Upload, App, Memory & Knowledge
163
-
164
- ```bash
165
- # Upload a local file to DashScope temp storage
166
- bl file upload --file ./photo.png --model qwen-vl-max
167
-
168
- # Call a Bailian application
169
- bl app call --app-id <APP_ID> --prompt "Hello" --stream
170
-
171
- # Memory management
172
- bl memory add --user-id user1 --content "User prefers Python"
173
- bl memory search --user-id user1 --query "programming language"
174
-
175
- # Knowledge base retrieval (requires AK/SK)
176
- bl knowledge retrieve --index-id <INDEX_ID> --query "search text"
177
-
178
- # Web search
179
- bl search web --query "latest TypeScript features" --count 5
180
- ```
181
-
182
- ## Authentication
183
-
184
- ### DashScope API Key
185
-
186
- Required for most commands. Get your key from the [DashScope Console](https://bailian.console.aliyun.com/cn-beijing/?source_channel=aliway&tab=app#/api-key).
187
-
188
- ```bash
189
- # Option 1: Environment variable
190
- export DASHSCOPE_API_KEY=sk-xxxxx
191
-
192
- # Option 2: Login command (persisted to ~/.bailian/config.json)
193
- bl auth login --api-key sk-xxxxx
194
-
195
- # Option 3: Per-command flag
196
- bl text chat --api-key sk-xxxxx --message "Hello"
197
- ```
198
-
199
- ### Alibaba Cloud AK/SK (Knowledge Base only)
200
-
201
- Required for `knowledge retrieve`. Get your AccessKey from [RAM Console](https://ram.console.aliyun.com/manage/ak).
202
-
203
- ```bash
204
- export ALIBABA_CLOUD_ACCESS_KEY_ID=LTAI5t...
205
- export ALIBABA_CLOUD_ACCESS_KEY_SECRET=...
206
- export BAILIAN_WORKSPACE_ID=ws-...
207
- ```
208
-
209
- ## Configuration
210
-
211
- ```bash
212
- # View current config
213
- bl config show
214
-
215
- # Set defaults
216
- bl config set --key region --value us
217
- bl config set --key default_text_model --value qwen-turbo
218
- bl config set --key timeout --value 600
219
-
220
- # Export MCP-compatible JSON Schema for all commands
221
- bl config export-schema
222
-
223
- # Self-update to latest version
224
- bl update
225
- ```
226
-
227
- Config file location: `~/.bailian/config.json`
228
-
229
- ## Global Flags
230
-
231
- | Flag | Description |
232
- |:-----|:------------|
233
- | `--api-key <key>` | API key (overrides all other auth) |
234
- | `--region <region>` | API region: `cn` (default), `us`, `intl` |
235
- | `--output <format>` | Output format: `text`, `json` |
236
- | `--quiet` | Suppress non-essential output |
237
- | `--verbose` | Print HTTP request/response details |
238
- | `--dry-run` | Show what would happen without executing |
239
- | `--no-color` | Disable ANSI colors and spinners |
240
- | `--timeout <seconds>` | Request timeout (default: 300) |
241
- | `--non-interactive` | Disable interactive prompts (CI mode) |
242
-
243
- ## Project Structure
244
-
245
- ```
246
- src/
247
- ├── main.ts # CLI entry point
248
- ├── registry.ts # Command registry (30 commands)
249
- ├── args.ts # Argument parsing
250
- ├── command.ts # Command interface & global options
251
- ├── auth/ # Authentication (credentials, resolver, setup)
252
- ├── client/ # HTTP client (AK signing, endpoints, streaming)
253
- ├── commands/ # Command implementations
254
- │ ├── auth/ # login, status, logout
255
- │ ├── text/ # chat
256
- │ ├── omni/ # multimodal chat
257
- │ ├── image/ # generate, edit
258
- │ ├── video/ # generate, edit, task-get, download
259
- │ ├── vision/ # describe
260
- │ ├── speech/ # synthesize, recognize
261
- │ ├── file/ # upload
262
- │ ├── app/ # call
263
- │ ├── memory/ # add, search, list, update, delete, profile
264
- │ ├── knowledge/ # retrieve
265
- │ ├── search/ # web
266
- │ └── config/ # show, set, export-schema
267
- ├── config/ # Config loading & schema (Zod)
268
- ├── errors/ # Error handling hierarchy
269
- ├── output/ # Formatters (text, json, progress, status-bar)
270
- ├── polling/ # Async task polling
271
- ├── update/ # Self-update checker
272
- └── utils/ # Utilities (fs, token, env, prompt)
273
- ```
274
-
275
- ## Links
276
-
277
- | Resource | URL |
278
- |:---------|:----|
279
- | DashScope API Docs | https://help.aliyun.com/zh/model-studio/ |
280
- | Qwen Model List | https://help.aliyun.com/zh/model-studio/getting-started/models |
281
- | Bailian Console | https://bailian.console.aliyun.com/ |
282
- | Get API Key | https://bailian.console.aliyun.com/cn-beijing/?source_channel=aliway&tab=app#/api-key |
283
- | Get AccessKey | https://ram.console.aliyun.com/manage/ak |
284
-
285
- <div align="center">
286
-
287
- ---
288
-
289
- Made with `>_` by the Bailian team
290
-
291
- </div>
@@ -1,69 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Preuninstall script: remove SKILL.md from all AI coding tools on uninstall.
5
- */
6
-
7
- import { existsSync, rmSync, openSync, writeSync, closeSync } from 'fs';
8
- import { join } from 'path';
9
- import { homedir } from 'os';
10
-
11
- const home = homedir();
12
-
13
- // Write directly to /dev/tty to bypass npm output suppression
14
- let ttyFd;
15
- try {
16
- ttyFd = openSync('/dev/tty', 'w');
17
- } catch {
18
- ttyFd = null;
19
- }
20
-
21
- function ttyPrint(msg) {
22
- if (ttyFd != null) {
23
- writeSync(ttyFd, msg + '\n');
24
- }
25
- }
26
-
27
- const dotDirTargets = [
28
- '.qoder',
29
- '.claude',
30
- '.cline',
31
- '.qwen',
32
- '.cursor',
33
- '.windsurf',
34
- '.trae',
35
- '.qoderwork',
36
- '.kiro',
37
- ];
38
-
39
- const customTargets = [
40
- { root: join(home, 'Library', 'Application Support', 'iDingTalk', 'wukong'), label: 'Wukong' },
41
- ];
42
-
43
- const targets = [
44
- ...dotDirTargets.map(d => ({ root: join(home, d), label: d })),
45
- ...customTargets,
46
- ];
47
-
48
- let removed = 0;
49
-
50
- for (const { root, label } of targets) {
51
- try {
52
- const skillDir = join(root, 'skills', 'bailian-cli');
53
- if (!existsSync(skillDir)) continue;
54
-
55
- rmSync(skillDir, { recursive: true });
56
- removed++;
57
- ttyPrint(` \u2717 ${label}`);
58
- } catch {
59
- // Silent fail — don't block npm uninstall
60
- }
61
- }
62
-
63
- if (removed > 0) {
64
- ttyPrint(`Bailian CLI skill removed from ${removed} AI coding tool(s).`);
65
- }
66
-
67
- if (ttyFd != null) {
68
- closeSync(ttyFd);
69
- }