u1s1-cli 1.11.8 → 1.13.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.d.ts +19 -3
- package/dist/agent-setup.js +85 -10
- package/dist/api.js +42 -34
- package/dist/bench-report.js +12 -9
- package/dist/bench.js +34 -31
- package/dist/brand.d.ts +2 -1
- package/dist/brand.js +38 -12
- package/dist/config.d.ts +11 -1
- package/dist/config.js +25 -8
- package/dist/context-usage.js +12 -9
- package/dist/deploy.js +49 -45
- package/dist/device-auth.js +7 -5
- package/dist/error-humanize.d.ts +1 -0
- package/dist/error-humanize.js +18 -6
- package/dist/feedback.js +48 -31
- package/dist/i18n.d.ts +21 -0
- package/dist/i18n.js +46 -0
- package/dist/import/index.js +64 -28
- package/dist/import/skills.js +72 -41
- package/dist/import/util.js +3 -2
- package/dist/import/write.js +2 -1
- package/dist/index.js +140 -49
- package/dist/login.js +39 -28
- package/dist/loop.js +18 -12
- package/dist/mcp/client.js +15 -14
- package/dist/mcp/command.d.ts +2 -2
- package/dist/mcp/command.js +109 -69
- package/dist/mcp/config.d.ts +22 -6
- package/dist/mcp/config.js +0 -0
- package/dist/mcp/extension.js +5 -3
- package/dist/mcp/tools.d.ts +2 -0
- package/dist/mcp/tools.js +10 -5
- package/dist/model.js +11 -10
- package/dist/nudges.d.ts +8 -2
- package/dist/nudges.js +22 -3
- package/dist/search-tools.js +7 -6
- package/dist/shell-doctor.js +9 -8
- package/dist/subagent.js +5 -4
- package/dist/tools.js +53 -37
- package/dist/update.js +29 -28
- package/dist/usage.d.ts +1 -1
- package/dist/usage.js +96 -43
- package/dist/web.js +2 -1
- package/dist/workflow/runner.js +33 -29
- package/dist/workflow/templates.js +70 -45
- package/dist/workflow/tool.js +15 -12
- package/package.json +4 -4
- package/scripts/patch-pi.js +347 -278
- package/scripts/render-regression.mjs +55 -4
|
@@ -6,16 +6,16 @@
|
|
|
6
6
|
* —— 隐藏的思考块不算可见内容、空标签跳过、隐形思考块后不加间隔空行
|
|
7
7
|
* 2. 扩展给内置工具的 renderShell:"self" + 空 Text —— 工具行零行渲染
|
|
8
8
|
*
|
|
9
|
-
* 本脚本用 pi
|
|
10
|
-
*
|
|
9
|
+
* 本脚本用 pi 真实组件模拟一轮对话并断言行数;另外核对补丁文案跟 U1S1_LANG 切中英。
|
|
10
|
+
* pi 升级后补丁没跟上、或扩展渲染被改动导致行数膨胀时,这里直接失败,挡在发布前。
|
|
11
11
|
*
|
|
12
12
|
* 运行:node scripts/render-regression.mjs(prepublishOnly 会自动跑)
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { Container, Spacer, Text, TuiMainScreen } from "@earendil-works/pi-tui";
|
|
16
|
-
import { existsSync } from "node:fs";
|
|
16
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
17
17
|
import { join, dirname } from "node:path";
|
|
18
|
-
import { fileURLToPath } from "node:url";
|
|
18
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
19
19
|
|
|
20
20
|
// pi 的 exports 不暴露 package.json 和 main,直接向上找 node_modules 里的包目录
|
|
21
21
|
// (npm 全局安装、pnpm workspace 都会把包放在搜索路径上的 node_modules 里)
|
|
@@ -177,6 +177,57 @@ tui.renderNow();
|
|
|
177
177
|
const deletionFrame = terminal.writes.join("");
|
|
178
178
|
checkTrue("Windows 删除行绘制关闭并恢复 autowrap", deletionFrame.includes("\x1b[?2026h\x1b[?7l") && deletionFrame.includes("\x1b[?7h\x1b[?2026l"));
|
|
179
179
|
|
|
180
|
+
// ---- 5. 补丁文案跟 U1S1_LANG 走:en(国际站)不能漏出中文,其余保持中文 ----
|
|
181
|
+
// 斜杠命令描述在模块加载时求值,换语言要带 query 重新 import 一份新实例;
|
|
182
|
+
// /hotkeys 表格是 handleHotkeysCommand 里现拼的模板串,从源码抠出来用桩变量求值。
|
|
183
|
+
const CJK = /[\u4e00-\u9fff\u3000-\u303f\uff00-\uffef]/;
|
|
184
|
+
const stripAnsi = (s) => s.replace(/\x1b\[[0-9;]*m/g, "");
|
|
185
|
+
const prevLang = process.env.U1S1_LANG;
|
|
186
|
+
const interactiveSrc = readFileSync(join(piRoot, "dist/modes/interactive/interactive-mode.js"), "utf8");
|
|
187
|
+
const hotkeysSrc = interactiveSrc.slice(
|
|
188
|
+
interactiveSrc.indexOf("let hotkeys = `"),
|
|
189
|
+
interactiveSrc.indexOf("// Add extension-registered shortcuts"),
|
|
190
|
+
);
|
|
191
|
+
const extHeaderSrc = interactiveSrc.slice(interactiveSrc.indexOf("hotkeys += `", interactiveSrc.indexOf("// Add extension-registered shortcuts")));
|
|
192
|
+
const extHeader = extHeaderSrc.slice("hotkeys += ".length, extHeaderSrc.indexOf("`;") + 1);
|
|
193
|
+
const titleExpr = interactiveSrc.match(/theme\.bold\(theme\.fg\("accent", (.*"Keyboard Shortcuts".*)\)\), 1, 0\)\);/)?.[1];
|
|
194
|
+
const keyVars = [...new Set([...hotkeysSrc.matchAll(/\$\{(\w+)\}/g)].map((m) => m[1]))];
|
|
195
|
+
function renderHotkeys() {
|
|
196
|
+
const fn = new Function(...keyVars, `${hotkeysSrc}\nreturn [${titleExpr ?? '"Keyboard Shortcuts"'}, hotkeys, ${extHeader}].join("\\n");`);
|
|
197
|
+
return fn(...keyVars.map((v) => `<${v}>`));
|
|
198
|
+
}
|
|
199
|
+
const { rawKeyHint } = await import(join(piRoot, "dist/modes/interactive/components/keybinding-hints.js"));
|
|
200
|
+
function renderErrorMessage() {
|
|
201
|
+
const c = new Container();
|
|
202
|
+
c.addChild(new AssistantMessageComponent({ role: "assistant", content: [], stopReason: "error" }, true, undefined, "", 1, []));
|
|
203
|
+
return stripAnsi(c.render(80).join("\n"));
|
|
204
|
+
}
|
|
205
|
+
try {
|
|
206
|
+
for (const lang of ["zh", "en"]) {
|
|
207
|
+
process.env.U1S1_LANG = lang;
|
|
208
|
+
const slashUrl = pathToFileURL(join(piRoot, "dist/core/slash-commands.js")).href + `?lang=${lang}`;
|
|
209
|
+
const { BUILTIN_SLASH_COMMANDS } = await import(slashUrl);
|
|
210
|
+
const slashText = BUILTIN_SLASH_COMMANDS.map((c) => `/${c.name} ${c.description}`).join("\n");
|
|
211
|
+
const hotkeysText = renderHotkeys();
|
|
212
|
+
const hintText = stripAnsi(rawKeyHint("esc", "cancel") + rawKeyHint("enter", "select"));
|
|
213
|
+
const errorText = renderErrorMessage();
|
|
214
|
+
if (lang === "en") {
|
|
215
|
+
checkTrue("U1S1_LANG=en 斜杠命令描述无中文", !CJK.test(slashText) && slashText.includes("Open settings menu"));
|
|
216
|
+
checkTrue("U1S1_LANG=en /hotkeys 表格无中文", !CJK.test(hotkeysText) && hotkeysText.includes("| Key | Action |") && hotkeysText.includes("Keyboard Shortcuts"));
|
|
217
|
+
checkTrue("U1S1_LANG=en 按键脚注无中文", !CJK.test(hintText) && hintText.includes("cancel"));
|
|
218
|
+
checkTrue("U1S1_LANG=en 报错文案无中文", !CJK.test(errorText) && errorText.includes("Error: Unknown error"));
|
|
219
|
+
} else {
|
|
220
|
+
checkTrue("U1S1_LANG=zh 斜杠命令描述为中文", slashText.includes("/settings 打开设置菜单") && !slashText.includes("Open settings menu"));
|
|
221
|
+
checkTrue("U1S1_LANG=zh /hotkeys 表格为中文", hotkeysText.includes("| 按键 | 操作 |") && hotkeysText.includes("快捷键一览") && !hotkeysText.includes("Move by word"));
|
|
222
|
+
checkTrue("U1S1_LANG=zh 按键脚注为中文", hintText.includes("取消") && hintText.includes("选择"));
|
|
223
|
+
checkTrue("U1S1_LANG=zh 报错文案为中文", errorText.includes("出错:未知错误"));
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
} finally {
|
|
227
|
+
if (prevLang === undefined) delete process.env.U1S1_LANG;
|
|
228
|
+
else process.env.U1S1_LANG = prevLang;
|
|
229
|
+
}
|
|
230
|
+
|
|
180
231
|
if (failed > 0) {
|
|
181
232
|
console.error(`\n渲染回归测试失败:${failed} 项。多半是 pi 升级后补丁没跟上,或扩展渲染被改动。`);
|
|
182
233
|
console.error("对照 patches/@earendil-works__pi-*.patch、patch-pi.js 和 agent-setup.ts 里的 writeCompactUiExtension 检查。");
|