@yivan-lab/pretty-please 1.3.0 → 1.4.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 +226 -624
- package/bin/pls.tsx +27 -7
- package/dist/bin/pls.js +25 -6
- package/dist/package.json +1 -1
- package/dist/src/components/CommandBox.js +2 -2
- package/dist/src/mastra-chat.js +4 -3
- package/dist/src/multi-step.js +4 -5
- package/dist/src/shell-hook.d.ts +19 -0
- package/dist/src/shell-hook.js +63 -0
- package/dist/src/system-history.d.ts +13 -0
- package/dist/src/system-history.js +105 -0
- package/dist/src/utils/console.d.ts +5 -0
- package/dist/src/utils/console.js +3 -1
- package/package.json +1 -1
- package/src/components/CommandBox.tsx +2 -2
- package/src/mastra-chat.ts +4 -2
- package/src/multi-step.ts +4 -3
- package/src/shell-hook.ts +76 -0
- package/src/system-history.ts +117 -0
- package/src/utils/console.ts +4 -1
package/README.md
CHANGED
|
@@ -1,187 +1,173 @@
|
|
|
1
1
|
# Pretty Please (pls)
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
<p align="center">
|
|
4
|
+
<strong>"Pretty please?" — 用最礼貌的方式,让 AI 帮你干活</strong>
|
|
5
|
+
</p>
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
> `please 查看当前目录` — 就像在跟电脑说话一样自然
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
<p align="center">
|
|
10
|
+
<img src="https://github.com/user-attachments/assets/e06a562c-f899-41d2-8870-d38ebc249904" alt="Pretty Please Demo" width="800">
|
|
11
|
+
</p>
|
|
8
12
|
|
|
9
|
-
|
|
10
|
-
- 🔄 **多步骤命令** - AI 自动规划多个步骤,后续命令依赖前面的执行结果
|
|
11
|
-
- 🛡️ **智能错误恢复** - 命令失败时 AI 自动分析并调整策略
|
|
12
|
-
- ✏️ **命令编辑** - 执行前可编辑 AI 生成的命令,支持 manual/auto 两种模式
|
|
13
|
-
- 💬 **AI 对话模式** - 随时问 AI 命令怎么用
|
|
14
|
-
- 🌐 **远程执行** - 通过 SSH 在远程服务器执行命令,支持密码/密钥认证
|
|
15
|
-
- 📜 **三种历史记录** - 命令历史、对话历史、Shell 历史统一管理
|
|
16
|
-
- 🎨 **精美界面** - 基于 React + Ink 的终端 UI,Markdown 渲染
|
|
17
|
-
- 🌗 **主题切换** - 支持 dark/light 主题,适配不同终端背景
|
|
18
|
-
- 🏷️ **命令别名** - 常用操作一键触发,支持参数模板
|
|
19
|
-
- 🔧 **多 Provider 支持** - 支持 OpenAI、DeepSeek、Anthropic 等多种 AI
|
|
20
|
-
- 🚀 **一键升级** - 内置 `pls upgrade` 命令,自动更新到最新版本
|
|
13
|
+
## 这是啥?
|
|
21
14
|
|
|
22
|
-
|
|
15
|
+
忘了 Shell 命令怎么写?没关系,用人话告诉 `pls` 你想干嘛就行。
|
|
23
16
|
|
|
24
|
-
|
|
17
|
+
**pretty please** 是英语里"拜托了"的意思,而我们的命令就叫 `pls` / `please`,所以每次执行命令都像是在礼貌地请求:
|
|
25
18
|
|
|
26
19
|
```bash
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
# 或使用 pnpm
|
|
31
|
-
pnpm add -g @yivan-lab/pretty-please
|
|
32
|
-
|
|
33
|
-
# 或使用 yarn
|
|
34
|
-
yarn global add @yivan-lab/pretty-please
|
|
20
|
+
please 帮我压缩这个文件夹
|
|
21
|
+
pls 找出占用 8080 端口的进程
|
|
22
|
+
pls 在服务器上重启 nginx
|
|
35
23
|
```
|
|
36
24
|
|
|
37
|
-
|
|
25
|
+
AI 生成命令 → 你确认 → 执行 → 搞定。
|
|
26
|
+
|
|
27
|
+
## ✨ 命令打错了?直接 `pls` 就行
|
|
38
28
|
|
|
39
|
-
|
|
29
|
+
像 [thefuck](https://github.com/nvbn/thefuck) 一样,命令执行失败后,直接输入 `pls` 让 AI 自动修复:
|
|
40
30
|
|
|
41
31
|
```bash
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
cd pretty-please
|
|
32
|
+
❯ python --version
|
|
33
|
+
zsh: command not found: python
|
|
45
34
|
|
|
46
|
-
#
|
|
47
|
-
|
|
35
|
+
❯ pls # ← 就这么简单!
|
|
36
|
+
✓ 生成命令: python3 --version
|
|
37
|
+
Python 3.9.6
|
|
38
|
+
```
|
|
48
39
|
|
|
49
|
-
|
|
50
|
-
|
|
40
|
+
```bash
|
|
41
|
+
❯ git pus origin main
|
|
42
|
+
git: 'pus' is not a git command. See 'git --help'.
|
|
51
43
|
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
❯ pls
|
|
45
|
+
✓ 生成命令: git push origin main
|
|
46
|
+
Enumerating objects: 5, done.
|
|
47
|
+
...
|
|
54
48
|
```
|
|
55
49
|
|
|
56
|
-
|
|
50
|
+
不用说"修复上一条命令",不用重新输入,**直接 `pls`,AI 自动检测失败的命令并生成正确版本**。
|
|
51
|
+
|
|
52
|
+
## 为什么用这个?
|
|
53
|
+
|
|
54
|
+
- **命令打错了?** 直接 `pls` 自动修复,像 thefuck 一样方便,但更智能
|
|
55
|
+
- 记不住 `tar` 的一堆参数
|
|
56
|
+
- 想批量处理文件但懒得写脚本
|
|
57
|
+
- 需要在多台服务器上执行同样的操作
|
|
58
|
+
- 想问问某个命令怎么用
|
|
57
59
|
|
|
58
|
-
|
|
60
|
+
## 能干啥?
|
|
59
61
|
|
|
60
|
-
|
|
62
|
+
**核心特性:**
|
|
63
|
+
- **自动修复错误** - 命令失败后直接 `pls`,AI 自动检测并生成正确命令(像 thefuck,但更智能)
|
|
64
|
+
- **自然语言转命令** - 生成前让你确认或编辑
|
|
65
|
+
- **智能多步任务** - 复杂任务自动拆分,每步基于上一步的结果
|
|
66
|
+
- **错误恢复重试** - 命令失败了 AI 会分析原因并调整策略
|
|
67
|
+
|
|
68
|
+
**高级功能:**
|
|
69
|
+
- **远程执行** - 通过 SSH 在服务器上跑命令,支持批量(`-r server1,server2,server3`)
|
|
70
|
+
- **对话模式** - `pls chat grep 怎么用`,随时问问题
|
|
71
|
+
- **命令别名** - 把常用操作存成快捷方式
|
|
72
|
+
- **主题系统** - 7 个内置主题 + 自定义主题
|
|
73
|
+
- **自动升级** - `pls upgrade` 一键更新
|
|
74
|
+
|
|
75
|
+
## 安装
|
|
76
|
+
|
|
77
|
+
**方式一:npm(推荐)**
|
|
61
78
|
|
|
62
|
-
**Linux / macOS:**
|
|
63
79
|
```bash
|
|
64
|
-
|
|
80
|
+
npm i -g @yivan-lab/pretty-please
|
|
65
81
|
```
|
|
66
82
|
|
|
67
|
-
|
|
68
|
-
|
|
83
|
+
**方式二:一键脚本(无需 Node.js)**
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Linux / macOS
|
|
87
|
+
curl -fsSL https://raw.githubusercontent.com/IvanLark/pretty-please/main/install.sh | bash
|
|
88
|
+
|
|
89
|
+
# Windows PowerShell
|
|
69
90
|
irm https://raw.githubusercontent.com/IvanLark/pretty-please/main/install.ps1 | iex
|
|
70
91
|
```
|
|
71
92
|
|
|
72
|
-
|
|
73
|
-
- Linux x64 / arm64
|
|
74
|
-
- macOS Intel / Apple Silicon
|
|
75
|
-
- Windows x64
|
|
76
|
-
|
|
77
|
-
## 🚀 快速开始
|
|
93
|
+
支持平台:Linux (x64/arm64) / macOS (Intel/Apple Silicon) / Windows x64
|
|
78
94
|
|
|
79
|
-
|
|
95
|
+
## 快速开始
|
|
80
96
|
|
|
81
|
-
|
|
97
|
+
**第一步:配置 API**
|
|
82
98
|
|
|
83
99
|
```bash
|
|
84
100
|
pls config
|
|
85
101
|
```
|
|
86
102
|
|
|
87
|
-
|
|
88
|
-
- **Provider**: openai / deepseek / anthropic 等(默认 openai)
|
|
89
|
-
- **Base URL**: API 地址
|
|
90
|
-
- **API Key**: 你的 API 密钥
|
|
91
|
-
- **Model**: 模型名称(如 gpt-4-turbo / deepseek-chat)
|
|
92
|
-
- **Shell Hook**: 是否启用Shell Hook(Shell Hook 可以记录你在终端执行的历史命令,让 AI 更智能地理解上下文,推荐启用)
|
|
103
|
+
按提示输入你的 AI API 信息(支持 OpenAI、DeepSeek、Claude 等)
|
|
93
104
|
|
|
94
|
-
|
|
105
|
+
**第二步:开始用**
|
|
95
106
|
|
|
96
107
|
```bash
|
|
97
|
-
# 生成并执行命令
|
|
98
108
|
pls 查看当前目录
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
pls 查找大于100MB的日志文件并压缩
|
|
102
|
-
|
|
103
|
-
# AI 对话模式
|
|
104
|
-
pls chat grep 命令怎么用
|
|
109
|
+
pls 找出大于100MB的文件
|
|
110
|
+
pls chat grep 怎么用
|
|
105
111
|
```
|
|
106
112
|
|
|
107
|
-
##
|
|
113
|
+
## 使用示例
|
|
108
114
|
|
|
109
|
-
###
|
|
115
|
+
### 基础用法
|
|
110
116
|
|
|
111
|
-
|
|
117
|
+
最简单的方式,直接说你想干啥:
|
|
112
118
|
|
|
113
119
|
```bash
|
|
114
120
|
pls 查看当前目录
|
|
115
121
|
pls 安装 git
|
|
116
|
-
pls
|
|
122
|
+
pls 找出占用 8080 端口的进程
|
|
117
123
|
pls 删除所有 .DS_Store 文件
|
|
118
124
|
```
|
|
119
125
|
|
|
120
|
-
AI
|
|
126
|
+
AI 生成命令,你确认后执行。
|
|
121
127
|
|
|
122
|
-
###
|
|
128
|
+
### 多步骤任务
|
|
123
129
|
|
|
124
|
-
|
|
130
|
+
复杂的任务 AI 会自动拆分,每步基于上一步的结果:
|
|
125
131
|
|
|
126
132
|
```bash
|
|
127
|
-
pls
|
|
133
|
+
pls 找出大于100MB的日志文件并压缩
|
|
128
134
|
```
|
|
129
135
|
|
|
130
|
-
|
|
131
|
-
1.
|
|
132
|
-
2.
|
|
133
|
-
3.
|
|
134
|
-
4. 完成!
|
|
135
|
-
|
|
136
|
-
每步执行后,AI 会根据实际输出结果智能地决定下一步怎么做。
|
|
136
|
+
**执行流程:**
|
|
137
|
+
1. 步骤 1:`find . -name '*.log' -size +100M` 找到了 `app.log` 和 `system.log`
|
|
138
|
+
2. 步骤 2:根据上一步的结果,生成 `tar -czf logs.tar.gz app.log system.log`
|
|
139
|
+
3. 完成!
|
|
137
140
|
|
|
138
|
-
###
|
|
141
|
+
### 引用历史
|
|
139
142
|
|
|
140
|
-
AI
|
|
143
|
+
AI 记得你之前干了啥:
|
|
141
144
|
|
|
142
145
|
```bash
|
|
143
|
-
|
|
144
|
-
pls
|
|
146
|
+
pls 创建一个 test.txt
|
|
147
|
+
pls 删除刚才的文件 # AI 知道你说的是 test.txt
|
|
145
148
|
|
|
146
|
-
#
|
|
147
|
-
pls 删除刚才创建的文件
|
|
148
|
-
# AI 会知道你说的是 test.txt
|
|
149
|
-
|
|
150
|
-
# 或者手动执行了某个命令
|
|
149
|
+
# 或者
|
|
151
150
|
mkdir my-project
|
|
152
151
|
cd my-project
|
|
153
|
-
|
|
154
|
-
# 然后让 AI 基于当前上下文工作
|
|
155
|
-
pls 在这个目录初始化 git 仓库
|
|
152
|
+
pls 在这个目录初始化 git 仓库 # AI 知道当前上下文
|
|
156
153
|
```
|
|
157
154
|
|
|
158
|
-
支持的引用方式:
|
|
159
|
-
- "刚才的文件"
|
|
160
|
-
- "上一个命令"
|
|
161
|
-
- "刚创建的目录"
|
|
162
|
-
- AI 会自动从历史记录中提取相关信息
|
|
163
|
-
|
|
164
155
|
### 错误恢复
|
|
165
156
|
|
|
166
|
-
|
|
157
|
+
命令失败了 AI 会分析并重试:
|
|
167
158
|
|
|
168
159
|
```bash
|
|
169
|
-
pls
|
|
160
|
+
pls 把 test.zip 移动到 a、b、c 三个文件夹
|
|
170
161
|
```
|
|
171
162
|
|
|
172
|
-
|
|
173
|
-
1.
|
|
174
|
-
2.
|
|
175
|
-
3. AI
|
|
176
|
-
4. **步骤 3**: `cp a/test.zip b/ && cp a/test.zip c/` ✓ 改用复制
|
|
163
|
+
**执行过程:**
|
|
164
|
+
1. `mv test.zip a/` ✓ 成功
|
|
165
|
+
2. `mv test.zip b/` ✗ 失败(文件已被移走)
|
|
166
|
+
3. AI 分析错误,改用复制:`cp a/test.zip b/ && cp a/test.zip c/` ✓ 成功
|
|
177
167
|
|
|
178
|
-
|
|
168
|
+
### 编辑命令
|
|
179
169
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
AI 生成的命令可能不完全符合你的需求,你可以在执行前编辑它:
|
|
183
|
-
|
|
184
|
-
**manual 模式(默认)**:
|
|
170
|
+
生成的命令不满意?按 `E` 编辑:
|
|
185
171
|
|
|
186
172
|
```
|
|
187
173
|
┌─ 生成命令 ───────┐
|
|
@@ -190,266 +176,76 @@ AI 生成的命令可能不完全符合你的需求,你可以在执行前编
|
|
|
190
176
|
|
|
191
177
|
执行? [回车执行 / E 编辑 / Esc 取消]
|
|
192
178
|
|
|
193
|
-
# 按 E
|
|
194
|
-
|
|
195
|
-
│ ls -la │ ← AI 建议
|
|
196
|
-
└──────────────────┘
|
|
197
|
-
> ls -l█ ← 可编辑
|
|
179
|
+
# 按 E 后进入编辑
|
|
180
|
+
> ls -l█ ← 可以修改
|
|
198
181
|
|
|
199
182
|
[回车执行 / Esc 返回]
|
|
200
183
|
```
|
|
201
184
|
|
|
202
|
-
|
|
185
|
+
或者用 `auto` 模式,自动进入编辑:
|
|
203
186
|
|
|
204
187
|
```bash
|
|
205
|
-
# 切换到 auto 模式
|
|
206
188
|
pls config set editMode auto
|
|
207
189
|
```
|
|
208
190
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
### 对话模式:命令讲解和问答
|
|
191
|
+
### 对话模式
|
|
212
192
|
|
|
213
|
-
|
|
193
|
+
想问问命令怎么用:
|
|
214
194
|
|
|
215
195
|
```bash
|
|
216
|
-
# 询问命令用法
|
|
217
196
|
pls chat tar 命令怎么用
|
|
218
|
-
|
|
219
|
-
# 解释刚才执行的命令
|
|
220
|
-
pls 找到所有 node_modules 目录并计算大小
|
|
221
|
-
pls chat 刚才那个命令是干嘛的?
|
|
222
|
-
# AI 会详细解释刚才生成的命令的含义和参数
|
|
223
|
-
|
|
224
|
-
# 提问题
|
|
225
|
-
pls chat 如何批量重命名文件
|
|
226
197
|
pls chat grep 和 awk 有什么区别
|
|
227
|
-
pls chat
|
|
228
|
-
|
|
229
|
-
# 清空对话历史
|
|
230
|
-
pls chat clear
|
|
198
|
+
pls chat 刚才那个命令是干嘛的? # 会解释你最近执行的命令
|
|
231
199
|
```
|
|
232
200
|
|
|
233
|
-
|
|
234
|
-
- 📖 **命令讲解** - 解释命令的含义、参数、用法
|
|
235
|
-
- 💡 **问题解答** - 回答 Shell、Linux、命令行相关问题
|
|
236
|
-
- 🎯 **上下文感知** - 能引用你刚才执行的命令
|
|
237
|
-
- 📝 **Markdown 渲染** - 支持代码高亮、表格、列表等精美格式
|
|
238
|
-
- 💬 **连续对话** - 保留历史,可以追问和深入讨论
|
|
201
|
+
### 远程执行
|
|
239
202
|
|
|
240
|
-
|
|
203
|
+
在服务器上跑命令:
|
|
241
204
|
|
|
242
205
|
```bash
|
|
243
|
-
#
|
|
244
|
-
pls history
|
|
245
|
-
|
|
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 历史
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
历史记录包含:
|
|
259
|
-
- 你的原始需求(自然语言)
|
|
260
|
-
- AI 生成的命令
|
|
261
|
-
- 用户修改后的命令(如有修改)
|
|
262
|
-
- 执行状态(成功/失败/退出码)
|
|
263
|
-
- 执行时间
|
|
264
|
-
|
|
265
|
-
## ⚙️ 配置管理
|
|
266
|
-
|
|
267
|
-
```bash
|
|
268
|
-
pls config # 交互式配置向导
|
|
269
|
-
pls config list # 查看当前配置
|
|
270
|
-
pls config show # 同上
|
|
271
|
-
pls config set <key> <value> # 设置单个配置项
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
### 配置项说明
|
|
275
|
-
|
|
276
|
-
| 配置项 | 说明 | 默认值 |
|
|
277
|
-
|--------|------|--------|
|
|
278
|
-
| `apiKey` | AI API 密钥 | - |
|
|
279
|
-
| `baseUrl` | API 基础 URL | `https://api.openai.com/v1` |
|
|
280
|
-
| `provider` | AI Provider | `openai` |
|
|
281
|
-
| `model` | 模型名称 | `gpt-4-turbo` |
|
|
282
|
-
| `shellHook` | 启用终端历史记录 | `false` |
|
|
283
|
-
| `editMode` | 命令编辑模式(manual/auto) | `manual` |
|
|
284
|
-
| `chatHistoryLimit` | 对话历史保留轮数 | `10` |
|
|
285
|
-
| `commandHistoryLimit` | 命令历史保留条数 | `10` |
|
|
286
|
-
| `shellHistoryLimit` | Shell 历史保留条数 | `15` |
|
|
287
|
-
| `theme` | 界面主题(dark/light) | `dark` |
|
|
288
|
-
| `aliases` | 命令别名配置 | `{}` |
|
|
289
|
-
|
|
290
|
-
### 支持的 Provider
|
|
291
|
-
|
|
292
|
-
- `openai` - OpenAI GPT 系列
|
|
293
|
-
- `deepseek` - DeepSeek
|
|
294
|
-
- `anthropic` - Claude
|
|
295
|
-
- `google` - Gemini
|
|
296
|
-
- `groq` - Groq
|
|
297
|
-
- `mistral` - Mistral AI
|
|
298
|
-
- `cohere` - Cohere
|
|
299
|
-
- `fireworks` - Fireworks AI
|
|
300
|
-
- `together` - Together AI
|
|
301
|
-
|
|
302
|
-
## 🌐 远程执行
|
|
303
|
-
|
|
304
|
-
通过 SSH 在远程服务器上执行 AI 生成的命令,支持密码/密钥认证。
|
|
305
|
-
|
|
306
|
-
### 添加远程服务器
|
|
307
|
-
|
|
308
|
-
```bash
|
|
309
|
-
# 使用默认密钥(~/.ssh/id_rsa)
|
|
206
|
+
# 添加服务器
|
|
310
207
|
pls remote add myserver root@192.168.1.100
|
|
311
208
|
|
|
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
|
-
# 指定服务器执行
|
|
209
|
+
# 远程执行
|
|
359
210
|
pls -r myserver 查看磁盘使用情况
|
|
360
|
-
pls -r myserver
|
|
361
|
-
|
|
362
|
-
# 使用默认服务器(需先设置)
|
|
363
|
-
pls -r 查看当前目录的文件
|
|
364
|
-
```
|
|
365
|
-
|
|
366
|
-
### 批量远程执行 ⭐
|
|
211
|
+
pls -r myserver 重启 nginx
|
|
367
212
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
```bash
|
|
371
|
-
# 批量执行(逗号分隔服务器名)
|
|
213
|
+
# 批量执行(在多台服务器上同时跑)
|
|
372
214
|
pls -r web1,web2,web3 查看 nginx 状态
|
|
373
|
-
pls -r server1,server2 查看磁盘使用情况
|
|
374
|
-
pls -r prod1,prod2,prod3 重启应用服务
|
|
375
215
|
```
|
|
376
216
|
|
|
377
|
-
|
|
378
|
-
- 🚀 **并发执行** - 所有服务器同时生成命令和执行,速度快
|
|
379
|
-
- 🔧 **自动适配** - 每个服务器根据其系统环境生成独立命令(支持异构环境)
|
|
380
|
-
- 📊 **清晰展示** - 显示每个服务器的命令和执行结果
|
|
381
|
-
- 📝 **历史记录** - 自动记录到每个服务器的历史
|
|
217
|
+
### 命令别名
|
|
382
218
|
|
|
383
|
-
|
|
219
|
+
把常用操作存成快捷方式:
|
|
384
220
|
|
|
385
221
|
```bash
|
|
386
|
-
|
|
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)
|
|
222
|
+
# 添加别名
|
|
223
|
+
pls alias add disk "查看磁盘使用情况,按使用率排序"
|
|
414
224
|
|
|
415
|
-
|
|
416
|
-
|
|
225
|
+
# 使用
|
|
226
|
+
pls disk
|
|
417
227
|
|
|
418
|
-
|
|
419
|
-
|
|
228
|
+
# 带参数的别名
|
|
229
|
+
pls alias add taillog "查看 {{file}} 的最后 {{lines:20}} 行"
|
|
230
|
+
pls taillog --file=/var/log/system.log --lines=50
|
|
420
231
|
```
|
|
421
232
|
|
|
422
|
-
|
|
423
|
-
- `0` - 全部成功
|
|
424
|
-
- `1` - 部分失败
|
|
425
|
-
- `2` - 全部失败
|
|
233
|
+
## 更多功能
|
|
426
234
|
|
|
427
|
-
|
|
428
|
-
- 批量执行模式不支持多步骤命令(只生成单个命令)
|
|
429
|
-
- 不支持命令编辑(直接执行生成的命令)
|
|
430
|
-
|
|
431
|
-
### 远程 Shell Hook
|
|
432
|
-
|
|
433
|
-
在远程服务器上安装 Shell Hook,让 AI 了解你在远程服务器上的操作历史:
|
|
235
|
+
### 历史记录
|
|
434
236
|
|
|
435
237
|
```bash
|
|
436
|
-
pls
|
|
437
|
-
pls
|
|
438
|
-
pls
|
|
439
|
-
```
|
|
440
|
-
|
|
441
|
-
### 远程历史记录
|
|
238
|
+
pls history # 命令历史
|
|
239
|
+
pls history chat # 对话历史
|
|
240
|
+
pls history shell # Shell 历史(需要启用 Shell Hook)
|
|
442
241
|
|
|
443
|
-
|
|
444
|
-
pls
|
|
445
|
-
pls remote history clear myserver # 清空远程命令历史
|
|
446
|
-
pls remote history shell myserver # 查看远程 Shell 历史
|
|
447
|
-
pls remote history shell-clear myserver # 清空远程 Shell 历史
|
|
242
|
+
pls history clear # 清空命令历史
|
|
243
|
+
pls history chat clear # 清空对话历史
|
|
448
244
|
```
|
|
449
245
|
|
|
450
|
-
|
|
246
|
+
### Shell Hook
|
|
451
247
|
|
|
452
|
-
|
|
248
|
+
记录你在终端执行的所有命令,让 AI 更了解上下文:
|
|
453
249
|
|
|
454
250
|
```bash
|
|
455
251
|
pls hook install # 安装 hook
|
|
@@ -457,381 +253,187 @@ pls hook status # 查看状态
|
|
|
457
253
|
pls hook uninstall # 卸载 hook
|
|
458
254
|
```
|
|
459
255
|
|
|
460
|
-
|
|
461
|
-
- zsh
|
|
462
|
-
- bash
|
|
463
|
-
- PowerShell
|
|
256
|
+
支持 zsh / bash / PowerShell。
|
|
464
257
|
|
|
465
|
-
|
|
258
|
+
### 主题
|
|
466
259
|
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
### 内置主题
|
|
260
|
+
7 个内置主题 + 自定义主题:
|
|
470
261
|
|
|
471
262
|
```bash
|
|
472
263
|
pls theme # 查看当前主题
|
|
473
|
-
pls theme list #
|
|
474
|
-
pls theme
|
|
475
|
-
pls theme nord # 切换到 Nord 主题
|
|
476
|
-
```
|
|
477
|
-
|
|
478
|
-
**可用的内置主题:**
|
|
479
|
-
- **dark(深色)** - 明亮的颜色,适合深色终端背景(默认)
|
|
480
|
-
- **light(浅色)** - 较深的颜色,适合浅色终端背景
|
|
481
|
-
- **nord(北欧冷色)** - 冷色调护眼主题,适合长时间使用
|
|
482
|
-
- **dracula(德古拉暗色)** - 高对比暗色主题,色彩丰富但不刺眼
|
|
483
|
-
- **retro(复古终端绿)** - 经典终端荧光绿,致敬老派 hacker 风格
|
|
484
|
-
- **contrast(高对比度)** - 极高对比度,适合视力辅助和强光环境
|
|
485
|
-
- **monokai(经典编辑器)** - Monokai 经典配色,开发者熟悉的选择
|
|
486
|
-
|
|
487
|
-
也可以通过配置命令切换:
|
|
488
|
-
|
|
489
|
-
```bash
|
|
490
|
-
pls config set theme nord
|
|
491
|
-
```
|
|
492
|
-
|
|
493
|
-
### 自定义主题
|
|
494
|
-
|
|
495
|
-
创建你自己的主题配色方案:
|
|
496
|
-
|
|
497
|
-
#### 1. 创建主题模板
|
|
498
|
-
|
|
499
|
-
```bash
|
|
500
|
-
# 创建深色主题
|
|
501
|
-
pls theme create my-ocean --display-name "我的海洋主题"
|
|
502
|
-
|
|
503
|
-
# 创建浅色主题
|
|
504
|
-
pls theme create my-light --display-name "我的浅色" --category light
|
|
505
|
-
```
|
|
506
|
-
|
|
507
|
-
这会在 `~/.please/themes/` 目录下生成一个 JSON 模板文件。
|
|
508
|
-
|
|
509
|
-
#### 2. 编辑主题文件
|
|
510
|
-
|
|
511
|
-
```bash
|
|
512
|
-
vim ~/.please/themes/my-ocean.json
|
|
264
|
+
pls theme list # 查看所有主题
|
|
265
|
+
pls theme nord # 切换主题
|
|
513
266
|
```
|
|
514
267
|
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
```json
|
|
518
|
-
{
|
|
519
|
-
"metadata": {
|
|
520
|
-
"name": "my-ocean",
|
|
521
|
-
"displayName": "我的海洋主题",
|
|
522
|
-
"description": "深邃的海洋蓝配色",
|
|
523
|
-
"category": "dark",
|
|
524
|
-
"author": "Your Name"
|
|
525
|
-
},
|
|
526
|
-
"colors": {
|
|
527
|
-
"primary": "#0077BE",
|
|
528
|
-
"secondary": "#5DADE2",
|
|
529
|
-
"accent": "#48C9B0",
|
|
530
|
-
"success": "#2ECC71",
|
|
531
|
-
"error": "#E74C3C",
|
|
532
|
-
"warning": "#F39C12",
|
|
533
|
-
"info": "#3498DB",
|
|
534
|
-
"text": {
|
|
535
|
-
"primary": "#ECF0F1",
|
|
536
|
-
"secondary": "#BDC3C7",
|
|
537
|
-
"muted": "#95A5A6",
|
|
538
|
-
"dim": "#7F8C8D"
|
|
539
|
-
},
|
|
540
|
-
"border": "#34495E",
|
|
541
|
-
"divider": "#2C3E50",
|
|
542
|
-
"code": {
|
|
543
|
-
"background": "#1C2833",
|
|
544
|
-
"text": "#ECF0F1",
|
|
545
|
-
"keyword": "#C678DD",
|
|
546
|
-
"string": "#98C379",
|
|
547
|
-
"function": "#61AFEF",
|
|
548
|
-
"comment": "#5C6370"
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
```
|
|
268
|
+
**内置主题:** dark、light、nord、dracula、retro、contrast、monokai
|
|
553
269
|
|
|
554
|
-
|
|
270
|
+
**自定义主题:**
|
|
555
271
|
|
|
556
272
|
```bash
|
|
557
|
-
pls theme
|
|
273
|
+
pls theme create my-theme --display-name "我的主题"
|
|
274
|
+
vim ~/.please/themes/my-theme.json # 编辑主题配置
|
|
275
|
+
pls theme validate ~/.please/themes/my-theme.json # 验证
|
|
276
|
+
pls theme my-theme # 应用
|
|
558
277
|
```
|
|
559
278
|
|
|
560
|
-
|
|
279
|
+
### 远程执行详细说明
|
|
561
280
|
|
|
562
|
-
|
|
281
|
+
**添加服务器:**
|
|
563
282
|
|
|
564
283
|
```bash
|
|
565
|
-
pls
|
|
284
|
+
pls remote add myserver root@192.168.1.100
|
|
285
|
+
pls remote add myserver root@192.168.1.100 --key ~/.ssh/my_key
|
|
286
|
+
pls remote add myserver root@192.168.1.100 --password # 密码认证
|
|
566
287
|
```
|
|
567
288
|
|
|
568
|
-
|
|
289
|
+
**管理服务器:**
|
|
569
290
|
|
|
570
291
|
```bash
|
|
571
|
-
#
|
|
572
|
-
pls
|
|
573
|
-
|
|
574
|
-
#
|
|
575
|
-
pls
|
|
576
|
-
|
|
577
|
-
# 只查看内置主题
|
|
578
|
-
pls theme list --builtin
|
|
292
|
+
pls remote # 查看所有服务器
|
|
293
|
+
pls remote test myserver # 测试连接
|
|
294
|
+
pls remote remove myserver # 删除
|
|
295
|
+
pls remote default myserver # 设置默认服务器
|
|
296
|
+
pls remote workdir myserver /var/www # 设置工作目录
|
|
579
297
|
```
|
|
580
298
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
**主题文件位置:** `~/.please/themes/`
|
|
584
|
-
|
|
585
|
-
**颜色格式:** 所有颜色必须使用十六进制格式(如 `#00D9FF`)
|
|
586
|
-
|
|
587
|
-
## 🏷️ 命令别名
|
|
588
|
-
|
|
589
|
-
将常用的操作保存为别名,一键触发:
|
|
590
|
-
|
|
591
|
-
### 基本使用
|
|
299
|
+
**远程执行:**
|
|
592
300
|
|
|
593
301
|
```bash
|
|
594
|
-
|
|
595
|
-
pls
|
|
596
|
-
pls alias add mem "查看内存使用最高的 10 个进程"
|
|
597
|
-
|
|
598
|
-
# 使用别名(两种格式都支持)
|
|
599
|
-
pls disk
|
|
600
|
-
pls @disk
|
|
601
|
-
|
|
602
|
-
# 查看所有别名
|
|
603
|
-
pls alias
|
|
604
|
-
pls alias list
|
|
302
|
+
pls -r myserver 查看磁盘使用情况
|
|
303
|
+
pls -r 查看当前目录 # 使用默认服务器
|
|
605
304
|
|
|
606
|
-
#
|
|
607
|
-
pls
|
|
305
|
+
# 批量执行
|
|
306
|
+
pls -r web1,web2,web3 重启 nginx
|
|
608
307
|
```
|
|
609
308
|
|
|
610
|
-
|
|
309
|
+
批量执行会为每个服务器生成适配其环境的命令,并发执行。
|
|
611
310
|
|
|
612
|
-
|
|
311
|
+
**远程历史:**
|
|
613
312
|
|
|
614
313
|
```bash
|
|
615
|
-
#
|
|
616
|
-
pls
|
|
617
|
-
|
|
618
|
-
# 使用时传参
|
|
619
|
-
pls taillog --file=/var/log/system.log # lines 使用默认值 20
|
|
620
|
-
pls taillog --file=/var/log/system.log --lines=50 # 自定义 lines
|
|
621
|
-
pls taillog file=/var/log/nginx.log lines=100 # 不带 -- 也可以
|
|
314
|
+
pls remote history show myserver # 查看
|
|
315
|
+
pls remote history clear myserver # 清空
|
|
316
|
+
pls remote hook install myserver # 安装远程 Hook
|
|
622
317
|
```
|
|
623
318
|
|
|
624
|
-
|
|
625
|
-
- `{{param}}` - 必填参数,不提供会报错
|
|
626
|
-
- `{{param:default}}` - 可选参数,有默认值
|
|
627
|
-
|
|
628
|
-
### 别名 + 额外描述
|
|
319
|
+
### 配置
|
|
629
320
|
|
|
630
|
-
|
|
321
|
+
查看和修改配置:
|
|
631
322
|
|
|
632
323
|
```bash
|
|
633
|
-
pls
|
|
324
|
+
pls config # 交互式配置
|
|
325
|
+
pls config list # 查看配置
|
|
326
|
+
pls config set <key> <value> # 修改单项
|
|
634
327
|
```
|
|
635
328
|
|
|
636
|
-
|
|
329
|
+
主要配置项:
|
|
330
|
+
- `apiKey` / `baseUrl` / `provider` / `model` - AI API 配置
|
|
331
|
+
- `editMode` - 命令编辑模式(manual / auto)
|
|
332
|
+
- `theme` - 界面主题
|
|
333
|
+
- `shellHook` - 是否启用 Shell Hook
|
|
334
|
+
- `chatHistoryLimit` / `commandHistoryLimit` - 历史条数限制
|
|
637
335
|
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
程序会每 24 小时检查一次新版本,发现更新时在命令结束后提示:
|
|
641
|
-
|
|
642
|
-
```
|
|
643
|
-
⚠ 发现新版本: 1.1.0 → 1.2.0,运行 pls upgrade 更新
|
|
644
|
-
```
|
|
336
|
+
支持的 Provider:openai、deepseek、anthropic、google、groq、mistral、cohere、fireworks、together
|
|
645
337
|
|
|
646
|
-
###
|
|
338
|
+
### 升级
|
|
647
339
|
|
|
648
340
|
```bash
|
|
649
|
-
# 升级到最新版本
|
|
650
|
-
pls upgrade
|
|
341
|
+
pls upgrade # 升级到最新版本
|
|
651
342
|
```
|
|
652
343
|
|
|
653
|
-
|
|
654
|
-
- **二进制安装**(curl/irm):自动下载并替换
|
|
655
|
-
- **npm 安装**:提示使用 `npm update -g @yivan-lab/pretty-please`
|
|
656
|
-
|
|
657
|
-
## 🎯 命令参考
|
|
344
|
+
程序每 24 小时自动检查更新,发现新版本会提示。
|
|
658
345
|
|
|
659
|
-
|
|
346
|
+
## 命令速查
|
|
660
347
|
|
|
661
348
|
```bash
|
|
662
|
-
|
|
663
|
-
pls
|
|
664
|
-
pls
|
|
665
|
-
pls -v
|
|
666
|
-
pls -h # 查看帮助
|
|
667
|
-
```
|
|
349
|
+
# 基础
|
|
350
|
+
pls <需求> # 生成并执行命令
|
|
351
|
+
pls -d <需求> # Debug 模式
|
|
352
|
+
pls -v # 查看版本
|
|
668
353
|
|
|
669
|
-
### 子命令
|
|
670
|
-
|
|
671
|
-
```bash
|
|
672
354
|
# 配置
|
|
673
|
-
pls config
|
|
674
|
-
pls config list
|
|
675
|
-
pls config set <key> <
|
|
355
|
+
pls config # 交互式配置
|
|
356
|
+
pls config list # 查看配置
|
|
357
|
+
pls config set <key> <val> # 修改配置
|
|
676
358
|
|
|
677
359
|
# 历史
|
|
678
|
-
pls history
|
|
679
|
-
pls history
|
|
680
|
-
pls history
|
|
681
|
-
pls history
|
|
682
|
-
pls history shell # Shell 历史
|
|
683
|
-
pls history shell clear # 清空 Shell 历史
|
|
360
|
+
pls history # 命令历史
|
|
361
|
+
pls history chat # 对话历史
|
|
362
|
+
pls history shell # Shell 历史
|
|
363
|
+
pls history clear # 清空历史
|
|
684
364
|
|
|
685
365
|
# 对话
|
|
686
|
-
pls chat <问题>
|
|
687
|
-
pls chat clear
|
|
366
|
+
pls chat <问题> # 问问题
|
|
367
|
+
pls history chat clear # 清空对话
|
|
688
368
|
|
|
689
|
-
#
|
|
690
|
-
pls hook
|
|
691
|
-
pls hook
|
|
692
|
-
pls hook uninstall
|
|
693
|
-
pls hook status
|
|
369
|
+
# Hook
|
|
370
|
+
pls hook install # 安装
|
|
371
|
+
pls hook status # 状态
|
|
372
|
+
pls hook uninstall # 卸载
|
|
694
373
|
|
|
695
374
|
# 主题
|
|
696
|
-
pls theme
|
|
697
|
-
pls theme list
|
|
698
|
-
pls theme <name>
|
|
699
|
-
|
|
700
|
-
# 自定义主题
|
|
701
|
-
pls theme create <name> --display-name "名称" # 创建主题模板
|
|
702
|
-
pls theme validate <file> # 验证主题文件
|
|
703
|
-
pls theme list --custom # 只显示自定义主题
|
|
704
|
-
pls theme list --builtin # 只显示内置主题
|
|
375
|
+
pls theme # 当前主题
|
|
376
|
+
pls theme list # 所有主题
|
|
377
|
+
pls theme <name> # 切换
|
|
705
378
|
|
|
706
379
|
# 别名
|
|
707
|
-
pls alias
|
|
708
|
-
pls alias
|
|
709
|
-
pls alias
|
|
710
|
-
pls alias remove <name> # 删除别名
|
|
711
|
-
|
|
712
|
-
# 升级
|
|
713
|
-
pls upgrade # 升级到最新版本
|
|
714
|
-
```
|
|
715
|
-
|
|
716
|
-
## 🏗️ 技术架构
|
|
717
|
-
|
|
718
|
-
### 核心技术栈
|
|
719
|
-
|
|
720
|
-
- **React 19 + Ink 6** - 终端 UI 组件化框架
|
|
721
|
-
- **Mastra 0.24** - AI Agent 框架,支持 Structured Output
|
|
722
|
-
- **TypeScript 5.9** - 100% TypeScript,完整类型安全
|
|
723
|
-
- **Zod 3.25** - Schema 验证
|
|
724
|
-
- **Commander 14** - CLI 参数解析
|
|
380
|
+
pls alias # 查看
|
|
381
|
+
pls alias add <name> "<prompt>" # 添加
|
|
382
|
+
pls alias remove <name> # 删除
|
|
725
383
|
|
|
726
|
-
|
|
384
|
+
# 远程
|
|
385
|
+
pls remote add <name> <user@host> # 添加服务器
|
|
386
|
+
pls remote list # 查看
|
|
387
|
+
pls -r <name> <需求> # 远程执行
|
|
388
|
+
pls -r <n1,n2,n3> <需求> # 批量执行
|
|
727
389
|
|
|
390
|
+
# 升级
|
|
391
|
+
pls upgrade # 升级到最新版本
|
|
728
392
|
```
|
|
729
|
-
pretty-please/
|
|
730
|
-
├── bin/
|
|
731
|
-
│ └── pls.tsx # 主入口
|
|
732
|
-
├── src/
|
|
733
|
-
│ ├── prompts.ts # 统一 AI 提示词管理
|
|
734
|
-
│ ├── mastra-agent.ts # Mastra Agent(命令生成)
|
|
735
|
-
│ ├── mastra-chat.ts # Mastra Chat Agent(对话模式)
|
|
736
|
-
│ ├── multi-step.ts # 多步骤命令核心
|
|
737
|
-
│ ├── config.ts # 配置管理
|
|
738
|
-
│ ├── history.ts # 命令历史
|
|
739
|
-
│ ├── chat-history.ts # 对话历史
|
|
740
|
-
│ ├── shell-hook.ts # Shell 集成
|
|
741
|
-
│ ├── builtin-detector.ts # Shell builtin 检测
|
|
742
|
-
│ ├── sysinfo.ts # 系统信息采集
|
|
743
|
-
│ ├── upgrade.ts # 版本升级模块
|
|
744
|
-
│ ├── alias.ts # 命令别名管理
|
|
745
|
-
│ ├── components/ # React Ink 组件
|
|
746
|
-
│ │ ├── MultiStepCommandGenerator.tsx
|
|
747
|
-
│ │ ├── Chat.tsx
|
|
748
|
-
│ │ ├── MarkdownDisplay.tsx
|
|
749
|
-
│ │ └── ...
|
|
750
|
-
│ ├── ui/
|
|
751
|
-
│ │ └── theme.ts # 主题系统
|
|
752
|
-
│ └── utils/
|
|
753
|
-
│ └── console.ts # 原生输出工具
|
|
754
|
-
├── package.json
|
|
755
|
-
└── tsconfig.json
|
|
756
|
-
```
|
|
757
|
-
|
|
758
|
-
## 🔨 开发指南
|
|
759
393
|
|
|
760
|
-
|
|
394
|
+
## 技术栈
|
|
761
395
|
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
396
|
+
- **React + Ink** - 终端 UI 组件化
|
|
397
|
+
- **Mastra** - AI Agent 框架
|
|
398
|
+
- **TypeScript** - 100% 类型安全
|
|
399
|
+
- **Commander** - CLI 参数解析
|
|
766
400
|
|
|
767
|
-
|
|
401
|
+
## 开发
|
|
768
402
|
|
|
769
403
|
```bash
|
|
770
|
-
|
|
404
|
+
git clone https://github.com/IvanLark/pretty-please.git
|
|
405
|
+
cd pretty-please
|
|
771
406
|
pnpm install
|
|
772
|
-
|
|
773
|
-
# 2. 构建并链接生产版本
|
|
774
407
|
pnpm build
|
|
775
408
|
pnpm link --global
|
|
776
|
-
|
|
777
|
-
# 3. 创建开发版本链接(需要全局安装 tsx)
|
|
778
|
-
pnpm add -g tsx
|
|
779
|
-
pnpm link:dev
|
|
780
409
|
```
|
|
781
410
|
|
|
782
|
-
|
|
411
|
+
开发模式(热重载):
|
|
783
412
|
|
|
784
413
|
```bash
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
# 或使用 dev 脚本
|
|
789
|
-
pnpm dev <参数>
|
|
790
|
-
```
|
|
791
|
-
|
|
792
|
-
代码修改会立即生效,无需重新编译。
|
|
793
|
-
|
|
794
|
-
### 构建和发布
|
|
795
|
-
|
|
796
|
-
```bash
|
|
797
|
-
# 构建
|
|
798
|
-
pnpm build
|
|
799
|
-
|
|
800
|
-
# 发布到 npm(会自动先执行 build)
|
|
801
|
-
npm publish
|
|
414
|
+
pnpm add -g tsx
|
|
415
|
+
pnpm link:dev
|
|
416
|
+
pls-dev <命令> # 代码修改立即生效
|
|
802
417
|
```
|
|
803
418
|
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
- 配置文件:`~/.please/config.json`
|
|
807
|
-
- 命令历史:`~/.please/history.json`
|
|
808
|
-
- 对话历史:`~/.please/chat_history.json`
|
|
809
|
-
- Shell 历史:`~/.please/shell_history.jsonl`
|
|
810
|
-
|
|
811
|
-
## 🐛 常见问题
|
|
812
|
-
|
|
813
|
-
### 为什么 Chat 会清空终端历史?
|
|
814
|
-
|
|
815
|
-
这是 Ink 的设计局限。我们采用了混合渲染模式,命令执行使用原生输出来保留历史,只有 Chat 模式会清空。
|
|
419
|
+
## 常见问题
|
|
816
420
|
|
|
817
|
-
|
|
421
|
+
**为什么 Chat 会清空终端历史?**
|
|
818
422
|
|
|
819
|
-
|
|
820
|
-
1. 使用 `--debug` 查看完整提示词
|
|
821
|
-
2. 检查 provider 和 model 配置是否正确
|
|
822
|
-
3. 某些模型需要 `jsonPromptInjection`(代码已自动处理)
|
|
423
|
+
这是 Ink 的设计局限。命令执行使用原生输出保留历史,只有 Chat 模式会清空。
|
|
823
424
|
|
|
824
|
-
|
|
425
|
+
**支持哪些 AI?**
|
|
825
426
|
|
|
826
|
-
|
|
427
|
+
支持 OpenAI、DeepSeek、Claude、Gemini、Groq、Mistral、Cohere 等,只要兼容 OpenAI API 格式就行。
|
|
827
428
|
|
|
828
|
-
##
|
|
429
|
+
## 许可证
|
|
829
430
|
|
|
830
431
|
MIT
|
|
831
432
|
|
|
832
|
-
##
|
|
433
|
+
## 致谢
|
|
833
434
|
|
|
834
|
-
- [
|
|
435
|
+
- [thefuck](https://github.com/nvbn/thefuck) - 启发了自动修复功能,一个超火的命令纠错工具
|
|
436
|
+
- [fuckit.sh](https://github.com/faithleysath/fuckit.sh) - 提供了灵感,一个优雅的 AI 命令行工具
|
|
835
437
|
- [Ink](https://github.com/vadimdemedes/ink) - 终端 React 渲染器
|
|
836
438
|
- [Mastra](https://mastra.ai) - AI Agent 框架
|
|
837
439
|
|