u1s1-cli 1.4.3 → 1.6.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/dist/agent-setup.js +27 -6
- package/dist/brand.js +1 -0
- package/dist/config.d.ts +2 -0
- package/dist/deploy.d.ts +5 -0
- package/dist/deploy.js +87 -26
- package/dist/embed.d.ts +1 -0
- package/dist/embed.js +1 -0
- package/dist/error-humanize.d.ts +7 -1
- package/dist/error-humanize.js +34 -2
- package/dist/feedback.d.ts +66 -0
- package/dist/feedback.js +200 -0
- package/dist/index.js +111 -4
- package/dist/nudges.d.ts +21 -0
- package/dist/nudges.js +40 -0
- package/dist/prompt.d.ts +5 -0
- package/dist/prompt.js +17 -0
- package/dist/request-trace.d.ts +12 -0
- package/dist/request-trace.js +45 -0
- package/dist/telemetry.d.ts +56 -0
- package/dist/telemetry.js +146 -0
- package/dist/update.js +2 -2
- package/dist/usage.d.ts +3 -0
- package/dist/usage.js +11 -1
- package/package.json +1 -1
- package/scripts/patch-pi.js +111 -1
package/scripts/patch-pi.js
CHANGED
|
@@ -90,7 +90,7 @@ const SLASH_COMMANDS_REPLACEMENTS = [
|
|
|
90
90
|
['{ name: "name", description: "Set session display name" },', '{ name: "name", description: "给当前会话起个名字" },'],
|
|
91
91
|
['{ name: "session", description: "Show session info and stats" },', '{ name: "session", description: "查看会话信息与统计" },'],
|
|
92
92
|
['{ name: "changelog", description: "Show changelog entries" },', '{ name: "changelog", description: "查看引擎更新日志(英文)" },'],
|
|
93
|
-
['{ name: "hotkeys", description: "Show all keyboard shortcuts" },', '{ name: "hotkeys", description: "查看全部快捷键
|
|
93
|
+
['{ name: "hotkeys", description: "Show all keyboard shortcuts" },', '{ name: "hotkeys", description: "查看全部快捷键" },'],
|
|
94
94
|
['{ name: "fork", description: "Create a new fork from a previous user message" },', '{ name: "fork", description: "从之前某条消息分叉出一个新会话" },'],
|
|
95
95
|
['{ name: "clone", description: "Duplicate the current session at the current position" },', '{ name: "clone", description: "复制当前会话再继续" },'],
|
|
96
96
|
['{ name: "trust", description: "Save project trust decision for future sessions" },', '{ name: "trust", description: "记住对这个项目目录的信任选择" },'],
|
|
@@ -103,6 +103,114 @@ const SLASH_COMMANDS_REPLACEMENTS = [
|
|
|
103
103
|
['{ name: "quit", description: `Quit ${APP_NAME}` },', '{ name: "quit", description: `退出 ${APP_NAME}` },'],
|
|
104
104
|
];
|
|
105
105
|
|
|
106
|
+
// 扩展报错文案汉化 + 默认不刷堆栈(dist/modes/interactive/interactive-mode.js),与 pnpm coding-agent patch 同步。
|
|
107
|
+
// 小白看到一屏英文 JS 堆栈只会以为程序坏了;一句中文 + 下一步(重启 / u1s1 feedback)就够。
|
|
108
|
+
const EXTENSION_ERROR_REPLACEMENTS = [
|
|
109
|
+
['const errorMsg = `Extension "${extensionPath}" error: ${error}`;', 'const errorMsg = `扩展 ${String(extensionPath).split(/[\\\\/]/).pop()} 出错(重启 u1s1 一般可恢复;反复出现请运行 u1s1 feedback 反馈):${error}`;'],
|
|
110
|
+
['if (stack) {', 'if (stack && process.env.U1S1_DEBUG_EXTENSIONS === "1") {'],
|
|
111
|
+
];
|
|
112
|
+
|
|
113
|
+
function patchExtensionError() {
|
|
114
|
+
for (const piDir of findPackageDirs("@earendil-works/pi-coding-agent")) {
|
|
115
|
+
const target = join(piDir, "dist", "modes", "interactive", "interactive-mode.js");
|
|
116
|
+
try {
|
|
117
|
+
let text = readFileSync(target, "utf8");
|
|
118
|
+
let applied = 0;
|
|
119
|
+
for (const [from, to] of EXTENSION_ERROR_REPLACEMENTS) {
|
|
120
|
+
if (text.includes(to)) {
|
|
121
|
+
applied++;
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (text.split(from).length !== 2) continue;
|
|
125
|
+
text = text.replace(from, to);
|
|
126
|
+
applied++;
|
|
127
|
+
}
|
|
128
|
+
if (applied < EXTENSION_ERROR_REPLACEMENTS.length) {
|
|
129
|
+
console.log(
|
|
130
|
+
`[u1s1] 提示: pi 版本可能已更新,扩展报错文案补丁只应用了 ${applied}/${EXTENSION_ERROR_REPLACEMENTS.length} 处(不影响使用)`,
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
writeFileSync(target, text);
|
|
134
|
+
} catch {
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// /hotkeys 快捷键表汉化(dist/modes/interactive/interactive-mode.js),与 pnpm coding-agent patch 同步。
|
|
141
|
+
// 表格由 pi 硬编码英文拼出来,启动横幅/help 都在引导新手输入 /hotkeys,整页英文等于没给。
|
|
142
|
+
// 只译说明列,按键显示(`${cursorUp}` 等)原样保留;表头出现 4 次,用 expected 计数整体替换。
|
|
143
|
+
const HOTKEYS_REPLACEMENTS = [
|
|
144
|
+
['"Keyboard Shortcuts"', '"快捷键一览"'],
|
|
145
|
+
["**Navigation**", "**移动**"],
|
|
146
|
+
["**Editing**", "**编辑**"],
|
|
147
|
+
["**Other**", "**其他**"],
|
|
148
|
+
["**Extensions**", "**扩展**"],
|
|
149
|
+
{ from: "| Key | Action |", to: "| 按键 | 操作 |", expected: 4 },
|
|
150
|
+
["| Move cursor / browse history |", "| 移动光标 / 翻看输入历史 |"],
|
|
151
|
+
["| Move by word |", "| 按词移动 |"],
|
|
152
|
+
["| Start of line |", "| 跳到行首 |"],
|
|
153
|
+
["| End of line |", "| 跳到行尾 |"],
|
|
154
|
+
["| Jump forward to character |", "| 向后跳到指定字符 |"],
|
|
155
|
+
["| Jump backward to character |", "| 向前跳到指定字符 |"],
|
|
156
|
+
["| Scroll by page |", "| 整页滚动 |"],
|
|
157
|
+
["| Send message |", "| 发送消息 |"],
|
|
158
|
+
['| New line${process.platform === "win32" ? " (Ctrl+Enter on Windows Terminal)" : ""} |', '| 换行${process.platform === "win32" ? "(Windows Terminal 用 Ctrl+Enter)" : ""} |'],
|
|
159
|
+
["| Delete word backwards |", "| 删除光标前一个词 |"],
|
|
160
|
+
["| Delete word forwards |", "| 删除光标后一个词 |"],
|
|
161
|
+
["| Delete to start of line |", "| 删到行首 |"],
|
|
162
|
+
["| Delete to end of line |", "| 删到行尾 |"],
|
|
163
|
+
["| Paste the most-recently-deleted text |", "| 粘贴最近删除的文本 |"],
|
|
164
|
+
["| Cycle through the deleted text after pasting |", "| 粘贴后在更早删除的文本间循环 |"],
|
|
165
|
+
["| Undo |", "| 撤销 |"],
|
|
166
|
+
["| Path completion / accept autocomplete |", "| 路径补全 / 接受自动补全 |"],
|
|
167
|
+
["| Cancel autocomplete / abort streaming |", "| 取消补全 / 中断模型回复 |"],
|
|
168
|
+
["| Clear editor (first) / exit (second) |", "| 清空输入框(再按一次退出) |"],
|
|
169
|
+
["| Exit (when editor is empty) |", "| 退出(输入框为空时) |"],
|
|
170
|
+
["| Suspend to background |", "| 挂起到后台 |"],
|
|
171
|
+
["| Cycle thinking level |", "| 切换思考深度 |"],
|
|
172
|
+
["| Cycle models |", "| 轮换模型 |"],
|
|
173
|
+
["| Open model selector |", "| 打开模型选择器 |"],
|
|
174
|
+
["| Toggle tool output expansion |", "| 展开 / 收起工具输出 |"],
|
|
175
|
+
["| Toggle thinking block visibility |", "| 显示 / 隐藏思考过程 |"],
|
|
176
|
+
["| Edit message in external editor |", "| 用外部编辑器写消息 |"],
|
|
177
|
+
["| Copy last assistant message |", "| 复制最近一条回复 |"],
|
|
178
|
+
["| Queue follow-up message |", "| 把消息排到当前回复之后 |"],
|
|
179
|
+
["| Restore queued messages |", "| 取回排队中的消息 |"],
|
|
180
|
+
["| Paste image or text from clipboard |", "| 从剪贴板粘贴图片或文本 |"],
|
|
181
|
+
["| Slash commands |", "| 斜杠命令(/help 看常用操作) |"],
|
|
182
|
+
["| Run bash command |", "| 运行终端命令 |"],
|
|
183
|
+
["| Run bash command (excluded from context) |", "| 运行终端命令(结果不进上下文) |"],
|
|
184
|
+
];
|
|
185
|
+
|
|
186
|
+
function patchHotkeys() {
|
|
187
|
+
for (const piDir of findPackageDirs("@earendil-works/pi-coding-agent")) {
|
|
188
|
+
const target = join(piDir, "dist", "modes", "interactive", "interactive-mode.js");
|
|
189
|
+
try {
|
|
190
|
+
let text = readFileSync(target, "utf8");
|
|
191
|
+
let applied = 0;
|
|
192
|
+
for (const rule of HOTKEYS_REPLACEMENTS) {
|
|
193
|
+
const { from, to, expected } = Array.isArray(rule) ? { from: rule[0], to: rule[1], expected: 1 } : rule;
|
|
194
|
+
if (text.includes(to)) {
|
|
195
|
+
applied++;
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
if (text.split(from).length !== expected + 1) continue;
|
|
199
|
+
text = text.split(from).join(to);
|
|
200
|
+
applied++;
|
|
201
|
+
}
|
|
202
|
+
if (applied < HOTKEYS_REPLACEMENTS.length) {
|
|
203
|
+
console.log(
|
|
204
|
+
`[u1s1] 提示: pi 版本可能已更新,/hotkeys 汉化补丁只应用了 ${applied}/${HOTKEYS_REPLACEMENTS.length} 处(不影响使用)`,
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
writeFileSync(target, text);
|
|
208
|
+
} catch {
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
106
214
|
function patchSlashCommands() {
|
|
107
215
|
for (const piDir of findPackageDirs("@earendil-works/pi-coding-agent")) {
|
|
108
216
|
const target = join(piDir, "dist", "core", "slash-commands.js");
|
|
@@ -219,6 +327,8 @@ const ENABLE_AUTOWRAP = "\\x1b[?7h";`,
|
|
|
219
327
|
try {
|
|
220
328
|
patchCompactUi();
|
|
221
329
|
patchSlashCommands();
|
|
330
|
+
patchExtensionError();
|
|
331
|
+
patchHotkeys();
|
|
222
332
|
patchMainScreenAutowrap();
|
|
223
333
|
} catch (err) {
|
|
224
334
|
console.log(`[u1s1] 提示: pi 运行时补丁未生效(${err?.message ?? err}),不影响安装`);
|