@yivan-lab/pretty-please 1.0.0 → 1.2.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.
- package/README.md +381 -28
- package/bin/pls.tsx +1138 -109
- package/dist/bin/pls.d.ts +1 -1
- package/dist/bin/pls.js +994 -91
- package/dist/package.json +80 -0
- package/dist/src/ai.d.ts +1 -41
- package/dist/src/ai.js +9 -190
- package/dist/src/alias.d.ts +41 -0
- package/dist/src/alias.js +240 -0
- package/dist/src/builtin-detector.d.ts +14 -8
- package/dist/src/builtin-detector.js +36 -16
- package/dist/src/chat-history.d.ts +16 -11
- package/dist/src/chat-history.js +35 -4
- package/dist/src/components/Chat.js +5 -4
- package/dist/src/components/CodeColorizer.js +26 -20
- package/dist/src/components/CommandBox.js +3 -17
- package/dist/src/components/ConfirmationPrompt.d.ts +2 -1
- package/dist/src/components/ConfirmationPrompt.js +9 -4
- package/dist/src/components/Duration.js +2 -1
- package/dist/src/components/InlineRenderer.js +2 -1
- package/dist/src/components/MarkdownDisplay.js +2 -1
- package/dist/src/components/MultiStepCommandGenerator.d.ts +5 -1
- package/dist/src/components/MultiStepCommandGenerator.js +127 -14
- package/dist/src/components/TableRenderer.js +2 -1
- package/dist/src/config.d.ts +59 -9
- package/dist/src/config.js +147 -48
- package/dist/src/history.d.ts +19 -5
- package/dist/src/history.js +26 -11
- package/dist/src/mastra-agent.d.ts +0 -1
- package/dist/src/mastra-agent.js +3 -4
- package/dist/src/mastra-chat.d.ts +28 -0
- package/dist/src/mastra-chat.js +93 -0
- package/dist/src/multi-step.d.ts +23 -7
- package/dist/src/multi-step.js +29 -6
- package/dist/src/prompts.d.ts +11 -0
- package/dist/src/prompts.js +140 -0
- package/dist/src/remote-history.d.ts +63 -0
- package/dist/src/remote-history.js +315 -0
- package/dist/src/remote.d.ts +113 -0
- package/dist/src/remote.js +634 -0
- package/dist/src/shell-hook.d.ts +87 -12
- package/dist/src/shell-hook.js +315 -17
- package/dist/src/sysinfo.d.ts +9 -5
- package/dist/src/sysinfo.js +2 -2
- package/dist/src/ui/theme.d.ts +27 -24
- package/dist/src/ui/theme.js +71 -21
- package/dist/src/upgrade.d.ts +41 -0
- package/dist/src/upgrade.js +348 -0
- package/dist/src/utils/console.d.ts +11 -11
- package/dist/src/utils/console.js +26 -17
- package/package.json +11 -9
- package/src/alias.ts +301 -0
- package/src/builtin-detector.ts +126 -0
- package/src/chat-history.ts +140 -0
- package/src/components/Chat.tsx +6 -5
- package/src/components/CodeColorizer.tsx +27 -19
- package/src/components/CommandBox.tsx +3 -17
- package/src/components/ConfirmationPrompt.tsx +11 -3
- package/src/components/Duration.tsx +2 -1
- package/src/components/InlineRenderer.tsx +2 -1
- package/src/components/MarkdownDisplay.tsx +2 -1
- package/src/components/MultiStepCommandGenerator.tsx +167 -16
- package/src/components/TableRenderer.tsx +2 -1
- package/src/config.ts +394 -0
- package/src/history.ts +160 -0
- package/src/mastra-agent.ts +3 -4
- package/src/mastra-chat.ts +124 -0
- package/src/multi-step.ts +45 -8
- package/src/prompts.ts +154 -0
- package/src/remote-history.ts +390 -0
- package/src/remote.ts +800 -0
- package/src/shell-hook.ts +754 -0
- package/src/{sysinfo.js → sysinfo.ts} +28 -16
- package/src/ui/theme.ts +101 -24
- package/src/upgrade.ts +397 -0
- package/src/utils/{console.js → console.ts} +36 -27
- package/bin/pls.js +0 -681
- package/src/ai.js +0 -324
- package/src/builtin-detector.js +0 -98
- package/src/chat-history.js +0 -94
- package/src/components/ChatStatus.tsx +0 -53
- package/src/components/CommandGenerator.tsx +0 -184
- package/src/components/ConfigDisplay.tsx +0 -64
- package/src/components/ConfigWizard.tsx +0 -101
- package/src/components/HistoryDisplay.tsx +0 -69
- package/src/components/HookManager.tsx +0 -150
- package/src/config.js +0 -221
- package/src/history.js +0 -131
- package/src/shell-hook.js +0 -393
package/README.md
CHANGED
|
@@ -9,10 +9,15 @@
|
|
|
9
9
|
- 🤖 **自然语言转命令** - 用人话说你想干什么,AI 自动生成命令
|
|
10
10
|
- 🔄 **多步骤命令** - AI 自动规划多个步骤,后续命令依赖前面的执行结果
|
|
11
11
|
- 🛡️ **智能错误恢复** - 命令失败时 AI 自动分析并调整策略
|
|
12
|
+
- ✏️ **命令编辑** - 执行前可编辑 AI 生成的命令,支持 manual/auto 两种模式
|
|
12
13
|
- 💬 **AI 对话模式** - 随时问 AI 命令怎么用
|
|
13
|
-
-
|
|
14
|
+
- 🌐 **远程执行** - 通过 SSH 在远程服务器执行命令,支持密码/密钥认证
|
|
15
|
+
- 📜 **三种历史记录** - 命令历史、对话历史、Shell 历史统一管理
|
|
14
16
|
- 🎨 **精美界面** - 基于 React + Ink 的终端 UI,Markdown 渲染
|
|
17
|
+
- 🌗 **主题切换** - 支持 dark/light 主题,适配不同终端背景
|
|
18
|
+
- 🏷️ **命令别名** - 常用操作一键触发,支持参数模板
|
|
15
19
|
- 🔧 **多 Provider 支持** - 支持 OpenAI、DeepSeek、Anthropic 等多种 AI
|
|
20
|
+
- 🚀 **一键升级** - 内置 `pls upgrade` 命令,自动更新到最新版本
|
|
16
21
|
|
|
17
22
|
## 📦 安装
|
|
18
23
|
|
|
@@ -29,33 +34,46 @@ pnpm add -g @yivan-lab/pretty-please
|
|
|
29
34
|
yarn global add @yivan-lab/pretty-please
|
|
30
35
|
```
|
|
31
36
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
npm install -g tsx
|
|
36
|
-
# 或
|
|
37
|
-
pnpm add -g tsx
|
|
38
|
-
```
|
|
37
|
+
安装完成后,你可以在任何目录使用 `pls` 或 `please` 命令了!
|
|
39
38
|
|
|
40
39
|
### 方式二:从源码安装
|
|
41
40
|
|
|
42
41
|
```bash
|
|
43
42
|
# 克隆项目
|
|
44
|
-
git clone https://github.com/
|
|
43
|
+
git clone https://github.com/IvanLark/pretty-please.git
|
|
45
44
|
cd pretty-please
|
|
46
45
|
|
|
47
46
|
# 安装依赖
|
|
48
47
|
pnpm install
|
|
49
48
|
|
|
49
|
+
# 构建
|
|
50
|
+
pnpm build
|
|
51
|
+
|
|
50
52
|
# 全局链接
|
|
51
53
|
pnpm link --global
|
|
52
|
-
|
|
53
|
-
# 确保全局安装了 tsx
|
|
54
|
-
pnpm add -g tsx
|
|
55
54
|
```
|
|
56
55
|
|
|
57
56
|
安装完成后,你可以在任何目录使用 `pls` 或 `please` 命令了!
|
|
58
57
|
|
|
58
|
+
### 方式三:一键安装(无需 Node.js)
|
|
59
|
+
|
|
60
|
+
适用于云服务器、DevOps 场景,无需 Node.js 环境:
|
|
61
|
+
|
|
62
|
+
**Linux / macOS:**
|
|
63
|
+
```bash
|
|
64
|
+
curl -fsSL https://raw.githubusercontent.com/IvanLark/pretty-please/main/install.sh | bash
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Windows (PowerShell):**
|
|
68
|
+
```powershell
|
|
69
|
+
irm https://raw.githubusercontent.com/IvanLark/pretty-please/main/install.ps1 | iex
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
支持的平台:
|
|
73
|
+
- Linux x64 / arm64
|
|
74
|
+
- macOS Intel / Apple Silicon
|
|
75
|
+
- Windows x64
|
|
76
|
+
|
|
59
77
|
## 🚀 快速开始
|
|
60
78
|
|
|
61
79
|
### 1. 配置 API
|
|
@@ -159,6 +177,37 @@ pls 将 test.zip 移动到 a、b、c 三个文件夹
|
|
|
159
177
|
|
|
160
178
|
AI 不会因为一次失败就放弃,而是理解错误原因并找到解决方案。
|
|
161
179
|
|
|
180
|
+
### 命令编辑
|
|
181
|
+
|
|
182
|
+
AI 生成的命令可能不完全符合你的需求,你可以在执行前编辑它:
|
|
183
|
+
|
|
184
|
+
**manual 模式(默认)**:
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
┌─ 生成命令 ───────┐
|
|
188
|
+
│ ls -la │
|
|
189
|
+
└──────────────────┘
|
|
190
|
+
|
|
191
|
+
执行? [回车执行 / E 编辑 / Esc 取消]
|
|
192
|
+
|
|
193
|
+
# 按 E 进入编辑
|
|
194
|
+
┌─ 生成命令 ───────┐
|
|
195
|
+
│ ls -la │ ← AI 建议
|
|
196
|
+
└──────────────────┘
|
|
197
|
+
> ls -l█ ← 可编辑
|
|
198
|
+
|
|
199
|
+
[回车执行 / Esc 返回]
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**auto 模式**:自动进入编辑,直接修改后执行
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
# 切换到 auto 模式
|
|
206
|
+
pls config set editMode auto
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
编辑后的命令会被记录到历史中,并标注修改前后的对比。
|
|
210
|
+
|
|
162
211
|
### 对话模式:命令讲解和问答
|
|
163
212
|
|
|
164
213
|
想了解某个命令怎么用?用 `pls chat` 开启对话模式:
|
|
@@ -191,16 +240,25 @@ pls chat clear
|
|
|
191
240
|
### 查看历史记录
|
|
192
241
|
|
|
193
242
|
```bash
|
|
194
|
-
#
|
|
243
|
+
# 查看命令历史
|
|
195
244
|
pls history
|
|
196
245
|
|
|
197
|
-
#
|
|
198
|
-
pls history
|
|
246
|
+
# 查看对话历史
|
|
247
|
+
pls history chat
|
|
248
|
+
|
|
249
|
+
# 查看 Shell 历史(需要启用 Shell Hook)
|
|
250
|
+
pls history shell
|
|
251
|
+
|
|
252
|
+
# 清空各种历史
|
|
253
|
+
pls history clear # 清空命令历史
|
|
254
|
+
pls history chat clear # 清空对话历史
|
|
255
|
+
pls history shell clear # 清空 Shell 历史
|
|
199
256
|
```
|
|
200
257
|
|
|
201
258
|
历史记录包含:
|
|
202
259
|
- 你的原始需求(自然语言)
|
|
203
260
|
- AI 生成的命令
|
|
261
|
+
- 用户修改后的命令(如有修改)
|
|
204
262
|
- 执行状态(成功/失败/退出码)
|
|
205
263
|
- 执行时间
|
|
206
264
|
|
|
@@ -222,7 +280,12 @@ pls config set <key> <value> # 设置单个配置项
|
|
|
222
280
|
| `provider` | AI Provider | `openai` |
|
|
223
281
|
| `model` | 模型名称 | `gpt-4-turbo` |
|
|
224
282
|
| `shellHook` | 启用终端历史记录 | `false` |
|
|
283
|
+
| `editMode` | 命令编辑模式(manual/auto) | `manual` |
|
|
225
284
|
| `chatHistoryLimit` | 对话历史保留轮数 | `10` |
|
|
285
|
+
| `commandHistoryLimit` | 命令历史保留条数 | `10` |
|
|
286
|
+
| `shellHistoryLimit` | Shell 历史保留条数 | `15` |
|
|
287
|
+
| `theme` | 界面主题(dark/light) | `dark` |
|
|
288
|
+
| `aliases` | 命令别名配置 | `{}` |
|
|
226
289
|
|
|
227
290
|
### 支持的 Provider
|
|
228
291
|
|
|
@@ -236,6 +299,154 @@ pls config set <key> <value> # 设置单个配置项
|
|
|
236
299
|
- `fireworks` - Fireworks AI
|
|
237
300
|
- `together` - Together AI
|
|
238
301
|
|
|
302
|
+
## 🌐 远程执行
|
|
303
|
+
|
|
304
|
+
通过 SSH 在远程服务器上执行 AI 生成的命令,支持密码/密钥认证。
|
|
305
|
+
|
|
306
|
+
### 添加远程服务器
|
|
307
|
+
|
|
308
|
+
```bash
|
|
309
|
+
# 使用默认密钥(~/.ssh/id_rsa)
|
|
310
|
+
pls remote add myserver root@192.168.1.100
|
|
311
|
+
|
|
312
|
+
# 指定端口
|
|
313
|
+
pls remote add myserver root@192.168.1.100:2222
|
|
314
|
+
|
|
315
|
+
# 使用指定密钥
|
|
316
|
+
pls remote add myserver root@192.168.1.100 --key ~/.ssh/my_key
|
|
317
|
+
|
|
318
|
+
# 使用密码认证(每次执行时输入密码)
|
|
319
|
+
pls remote add myserver root@192.168.1.100 --password
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### 管理远程服务器
|
|
323
|
+
|
|
324
|
+
```bash
|
|
325
|
+
pls remote # 查看所有服务器
|
|
326
|
+
pls remote list # 同上
|
|
327
|
+
pls remote test myserver # 测试连接并采集系统信息
|
|
328
|
+
pls remote remove myserver # 删除服务器
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### 设置默认服务器
|
|
332
|
+
|
|
333
|
+
```bash
|
|
334
|
+
pls remote default myserver # 设置默认服务器
|
|
335
|
+
pls remote default # 查看当前默认服务器
|
|
336
|
+
pls remote default --clear # 清除默认服务器
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
设置默认服务器后,使用 `-r` 参数时可以省略服务器名:
|
|
340
|
+
|
|
341
|
+
```bash
|
|
342
|
+
pls -r 查看磁盘使用情况 # 使用默认服务器
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
### 设置工作目录
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
pls remote workdir myserver /var/www # 设置工作目录
|
|
349
|
+
pls remote workdir myserver # 查看当前工作目录
|
|
350
|
+
pls remote workdir myserver --clear # 清除工作目录
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
设置工作目录后,所有命令会自动在该目录下执行。
|
|
354
|
+
|
|
355
|
+
### 远程执行命令
|
|
356
|
+
|
|
357
|
+
```bash
|
|
358
|
+
# 指定服务器执行
|
|
359
|
+
pls -r myserver 查看磁盘使用情况
|
|
360
|
+
pls -r myserver 查找大于 100MB 的日志文件
|
|
361
|
+
|
|
362
|
+
# 使用默认服务器(需先设置)
|
|
363
|
+
pls -r 查看当前目录的文件
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
### 批量远程执行 ⭐
|
|
367
|
+
|
|
368
|
+
在多台服务器上并发执行同一个任务,每个服务器自动生成适配其环境的命令:
|
|
369
|
+
|
|
370
|
+
```bash
|
|
371
|
+
# 批量执行(逗号分隔服务器名)
|
|
372
|
+
pls -r web1,web2,web3 查看 nginx 状态
|
|
373
|
+
pls -r server1,server2 查看磁盘使用情况
|
|
374
|
+
pls -r prod1,prod2,prod3 重启应用服务
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
**特点:**
|
|
378
|
+
- 🚀 **并发执行** - 所有服务器同时生成命令和执行,速度快
|
|
379
|
+
- 🔧 **自动适配** - 每个服务器根据其系统环境生成独立命令(支持异构环境)
|
|
380
|
+
- 📊 **清晰展示** - 显示每个服务器的命令和执行结果
|
|
381
|
+
- 📝 **历史记录** - 自动记录到每个服务器的历史
|
|
382
|
+
|
|
383
|
+
**执行流程示例:**
|
|
384
|
+
|
|
385
|
+
```bash
|
|
386
|
+
$ pls -r web1,web2,web3 查看 nginx 状态
|
|
387
|
+
|
|
388
|
+
正在为 3 台服务器生成命令...
|
|
389
|
+
|
|
390
|
+
✓ 命令生成完成
|
|
391
|
+
|
|
392
|
+
web1 (linux):
|
|
393
|
+
systemctl status nginx | grep Active
|
|
394
|
+
|
|
395
|
+
web2 (linux):
|
|
396
|
+
systemctl status nginx | grep Active
|
|
397
|
+
|
|
398
|
+
web3 (linux):
|
|
399
|
+
systemctl status nginx | grep Active
|
|
400
|
+
|
|
401
|
+
将在 3 台服务器执行以上命令
|
|
402
|
+
执行? [回车执行 / Ctrl+C 取消]
|
|
403
|
+
|
|
404
|
+
正在执行...
|
|
405
|
+
|
|
406
|
+
执行完成:
|
|
407
|
+
|
|
408
|
+
✓ web1 (退出码: 0)
|
|
409
|
+
✓ web2 (退出码: 0)
|
|
410
|
+
✗ web3 (退出码: 3)
|
|
411
|
+
|
|
412
|
+
─── web1 ───
|
|
413
|
+
Active: active (running)
|
|
414
|
+
|
|
415
|
+
─── web2 ───
|
|
416
|
+
Active: active (running)
|
|
417
|
+
|
|
418
|
+
─── web3 ───
|
|
419
|
+
Active: inactive (dead)
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
**退出码:**
|
|
423
|
+
- `0` - 全部成功
|
|
424
|
+
- `1` - 部分失败
|
|
425
|
+
- `2` - 全部失败
|
|
426
|
+
|
|
427
|
+
**限制:**
|
|
428
|
+
- 批量执行模式不支持多步骤命令(只生成单个命令)
|
|
429
|
+
- 不支持命令编辑(直接执行生成的命令)
|
|
430
|
+
|
|
431
|
+
### 远程 Shell Hook
|
|
432
|
+
|
|
433
|
+
在远程服务器上安装 Shell Hook,让 AI 了解你在远程服务器上的操作历史:
|
|
434
|
+
|
|
435
|
+
```bash
|
|
436
|
+
pls remote hook install myserver # 安装远程 Hook
|
|
437
|
+
pls remote hook status myserver # 查看状态
|
|
438
|
+
pls remote hook uninstall myserver # 卸载 Hook
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
### 远程历史记录
|
|
442
|
+
|
|
443
|
+
```bash
|
|
444
|
+
pls remote history show myserver # 查看远程命令历史
|
|
445
|
+
pls remote history clear myserver # 清空远程命令历史
|
|
446
|
+
pls remote history shell myserver # 查看远程 Shell 历史
|
|
447
|
+
pls remote history shell-clear myserver # 清空远程 Shell 历史
|
|
448
|
+
```
|
|
449
|
+
|
|
239
450
|
## 🔧 Shell Hook(可选)
|
|
240
451
|
|
|
241
452
|
Shell Hook 可以记录你在终端执行的所有命令,让 AI 更智能地理解上下文。
|
|
@@ -251,6 +462,97 @@ pls hook uninstall # 卸载 hook
|
|
|
251
462
|
- bash
|
|
252
463
|
- PowerShell
|
|
253
464
|
|
|
465
|
+
## 🌗 主题系统
|
|
466
|
+
|
|
467
|
+
支持深色和浅色两种主题,适配不同终端背景:
|
|
468
|
+
|
|
469
|
+
```bash
|
|
470
|
+
pls theme # 查看当前主题
|
|
471
|
+
pls theme list # 查看所有可用主题
|
|
472
|
+
pls theme dark # 切换到深色主题
|
|
473
|
+
pls theme light # 切换到浅色主题
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
主题说明:
|
|
477
|
+
- **dark(深色)** - 明亮的颜色,适合深色终端背景(默认)
|
|
478
|
+
- **light(浅色)** - 较深的颜色,适合浅色终端背景
|
|
479
|
+
|
|
480
|
+
也可以通过配置命令切换:
|
|
481
|
+
|
|
482
|
+
```bash
|
|
483
|
+
pls config set theme light
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
## 🏷️ 命令别名
|
|
487
|
+
|
|
488
|
+
将常用的操作保存为别名,一键触发:
|
|
489
|
+
|
|
490
|
+
### 基本使用
|
|
491
|
+
|
|
492
|
+
```bash
|
|
493
|
+
# 添加简单别名
|
|
494
|
+
pls alias add disk "查看磁盘使用情况,按使用率排序"
|
|
495
|
+
pls alias add mem "查看内存使用最高的 10 个进程"
|
|
496
|
+
|
|
497
|
+
# 使用别名(两种格式都支持)
|
|
498
|
+
pls disk
|
|
499
|
+
pls @disk
|
|
500
|
+
|
|
501
|
+
# 查看所有别名
|
|
502
|
+
pls alias
|
|
503
|
+
pls alias list
|
|
504
|
+
|
|
505
|
+
# 删除别名
|
|
506
|
+
pls alias remove disk
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
### 参数模板
|
|
510
|
+
|
|
511
|
+
支持动态参数,让别名更灵活:
|
|
512
|
+
|
|
513
|
+
```bash
|
|
514
|
+
# 添加带参数的别名
|
|
515
|
+
pls alias add taillog "查看 {{file}} 的最后 {{lines:20}} 行日志"
|
|
516
|
+
|
|
517
|
+
# 使用时传参
|
|
518
|
+
pls taillog --file=/var/log/system.log # lines 使用默认值 20
|
|
519
|
+
pls taillog --file=/var/log/system.log --lines=50 # 自定义 lines
|
|
520
|
+
pls taillog file=/var/log/nginx.log lines=100 # 不带 -- 也可以
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
参数格式说明:
|
|
524
|
+
- `{{param}}` - 必填参数,不提供会报错
|
|
525
|
+
- `{{param:default}}` - 可选参数,有默认值
|
|
526
|
+
|
|
527
|
+
### 别名 + 额外描述
|
|
528
|
+
|
|
529
|
+
别名后可以追加额外的描述:
|
|
530
|
+
|
|
531
|
+
```bash
|
|
532
|
+
pls disk 显示详情 # 等同于 pls 查看磁盘使用情况,按使用率排序 显示详情
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
## 🚀 版本升级
|
|
536
|
+
|
|
537
|
+
### 自动更新提示
|
|
538
|
+
|
|
539
|
+
程序会每 24 小时检查一次新版本,发现更新时在命令结束后提示:
|
|
540
|
+
|
|
541
|
+
```
|
|
542
|
+
⚠ 发现新版本: 1.1.0 → 1.2.0,运行 pls upgrade 更新
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
### 升级命令
|
|
546
|
+
|
|
547
|
+
```bash
|
|
548
|
+
# 升级到最新版本
|
|
549
|
+
pls upgrade
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
升级方式:
|
|
553
|
+
- **二进制安装**(curl/irm):自动下载并替换
|
|
554
|
+
- **npm 安装**:提示使用 `npm update -g @yivan-lab/pretty-please`
|
|
555
|
+
|
|
254
556
|
## 🎯 命令参考
|
|
255
557
|
|
|
256
558
|
### 基础命令
|
|
@@ -272,8 +574,12 @@ pls config list
|
|
|
272
574
|
pls config set <key> <value>
|
|
273
575
|
|
|
274
576
|
# 历史
|
|
275
|
-
pls history
|
|
276
|
-
pls history clear
|
|
577
|
+
pls history # 命令历史
|
|
578
|
+
pls history clear # 清空命令历史
|
|
579
|
+
pls history chat # 对话历史
|
|
580
|
+
pls history chat clear # 清空对话历史
|
|
581
|
+
pls history shell # Shell 历史
|
|
582
|
+
pls history shell clear # 清空 Shell 历史
|
|
277
583
|
|
|
278
584
|
# 对话
|
|
279
585
|
pls chat <问题>
|
|
@@ -284,6 +590,20 @@ pls hook
|
|
|
284
590
|
pls hook install
|
|
285
591
|
pls hook uninstall
|
|
286
592
|
pls hook status
|
|
593
|
+
|
|
594
|
+
# 主题
|
|
595
|
+
pls theme # 查看当前主题
|
|
596
|
+
pls theme list # 查看所有主题
|
|
597
|
+
pls theme <dark|light> # 切换主题
|
|
598
|
+
|
|
599
|
+
# 别名
|
|
600
|
+
pls alias # 查看所有别名
|
|
601
|
+
pls alias list # 同上
|
|
602
|
+
pls alias add <name> "<prompt>" # 添加别名
|
|
603
|
+
pls alias remove <name> # 删除别名
|
|
604
|
+
|
|
605
|
+
# 升级
|
|
606
|
+
pls upgrade # 升级到最新版本
|
|
287
607
|
```
|
|
288
608
|
|
|
289
609
|
## 🏗️ 技术架构
|
|
@@ -292,7 +612,7 @@ pls hook status
|
|
|
292
612
|
|
|
293
613
|
- **React 19 + Ink 6** - 终端 UI 组件化框架
|
|
294
614
|
- **Mastra 0.24** - AI Agent 框架,支持 Structured Output
|
|
295
|
-
- **TypeScript 5.9** -
|
|
615
|
+
- **TypeScript 5.9** - 100% TypeScript,完整类型安全
|
|
296
616
|
- **Zod 3.25** - Schema 验证
|
|
297
617
|
- **Commander 14** - CLI 参数解析
|
|
298
618
|
|
|
@@ -303,31 +623,60 @@ pretty-please/
|
|
|
303
623
|
├── bin/
|
|
304
624
|
│ └── pls.tsx # 主入口
|
|
305
625
|
├── src/
|
|
306
|
-
│ ├──
|
|
307
|
-
│ ├── mastra-agent.ts # Mastra Agent
|
|
626
|
+
│ ├── prompts.ts # 统一 AI 提示词管理
|
|
627
|
+
│ ├── mastra-agent.ts # Mastra Agent(命令生成)
|
|
628
|
+
│ ├── mastra-chat.ts # Mastra Chat Agent(对话模式)
|
|
308
629
|
│ ├── multi-step.ts # 多步骤命令核心
|
|
309
|
-
│ ├── config.
|
|
310
|
-
│ ├── history.
|
|
311
|
-
│ ├── chat-history.
|
|
312
|
-
│ ├── shell-hook.
|
|
630
|
+
│ ├── config.ts # 配置管理
|
|
631
|
+
│ ├── history.ts # 命令历史
|
|
632
|
+
│ ├── chat-history.ts # 对话历史
|
|
633
|
+
│ ├── shell-hook.ts # Shell 集成
|
|
634
|
+
│ ├── builtin-detector.ts # Shell builtin 检测
|
|
635
|
+
│ ├── sysinfo.ts # 系统信息采集
|
|
636
|
+
│ ├── upgrade.ts # 版本升级模块
|
|
637
|
+
│ ├── alias.ts # 命令别名管理
|
|
313
638
|
│ ├── components/ # React Ink 组件
|
|
314
639
|
│ │ ├── MultiStepCommandGenerator.tsx
|
|
315
640
|
│ │ ├── Chat.tsx
|
|
316
641
|
│ │ ├── MarkdownDisplay.tsx
|
|
317
642
|
│ │ └── ...
|
|
643
|
+
│ ├── ui/
|
|
644
|
+
│ │ └── theme.ts # 主题系统
|
|
318
645
|
│ └── utils/
|
|
319
|
-
│ └── console.
|
|
646
|
+
│ └── console.ts # 原生输出工具
|
|
320
647
|
├── package.json
|
|
321
648
|
└── tsconfig.json
|
|
322
649
|
```
|
|
323
650
|
|
|
324
651
|
## 🔨 开发指南
|
|
325
652
|
|
|
653
|
+
### 命令版本
|
|
654
|
+
|
|
655
|
+
| 命令 | 类型 | 说明 |
|
|
656
|
+
|------|------|------|
|
|
657
|
+
| `pls` / `please` | 生产版本 | 编译后的 JS |
|
|
658
|
+
| `pls-dev` | 开发版本 | 热重载,代码修改立即生效 |
|
|
659
|
+
|
|
660
|
+
### 首次设置
|
|
661
|
+
|
|
662
|
+
```bash
|
|
663
|
+
# 1. 安装依赖
|
|
664
|
+
pnpm install
|
|
665
|
+
|
|
666
|
+
# 2. 构建并链接生产版本
|
|
667
|
+
pnpm build
|
|
668
|
+
pnpm link --global
|
|
669
|
+
|
|
670
|
+
# 3. 创建开发版本链接(需要全局安装 tsx)
|
|
671
|
+
pnpm add -g tsx
|
|
672
|
+
pnpm link:dev
|
|
673
|
+
```
|
|
674
|
+
|
|
326
675
|
### 开发模式
|
|
327
676
|
|
|
328
677
|
```bash
|
|
329
|
-
#
|
|
330
|
-
pls <命令>
|
|
678
|
+
# 使用开发命令(推荐,热重载)
|
|
679
|
+
pls-dev <命令>
|
|
331
680
|
|
|
332
681
|
# 或使用 dev 脚本
|
|
333
682
|
pnpm dev <参数>
|
|
@@ -335,10 +684,14 @@ pnpm dev <参数>
|
|
|
335
684
|
|
|
336
685
|
代码修改会立即生效,无需重新编译。
|
|
337
686
|
|
|
338
|
-
###
|
|
687
|
+
### 构建和发布
|
|
339
688
|
|
|
340
689
|
```bash
|
|
690
|
+
# 构建
|
|
341
691
|
pnpm build
|
|
692
|
+
|
|
693
|
+
# 发布到 npm(会自动先执行 build)
|
|
694
|
+
npm publish
|
|
342
695
|
```
|
|
343
696
|
|
|
344
697
|
### 目录说明
|