u1s1-cli 0.16.1 → 0.16.3
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 +3 -1
- package/dist/update.js +23 -3
- package/package.json +1 -1
- package/scripts/patch-pi.js +30 -12
package/dist/agent-setup.js
CHANGED
|
@@ -214,7 +214,9 @@ export default async function (pi) {
|
|
|
214
214
|
renderResult(result, { expanded }, theme, context) {
|
|
215
215
|
if (context.isError) {
|
|
216
216
|
const c = result.content.find((x) => x.type === "text");
|
|
217
|
-
|
|
217
|
+
const msg = oneLine(c && c.type === "text" ? c.text : "error");
|
|
218
|
+
// 低调处理:✗ 用警示色,内容用灰色弱化,避免满屏安静时红字过于扎眼
|
|
219
|
+
return new Text(theme.fg("warning", "✗ ") + theme.fg("muted", msg), 0, 0);
|
|
218
220
|
}
|
|
219
221
|
if (!expanded) return new Text("", 0, 0);
|
|
220
222
|
const c = result.content.find((x) => x.type === "text");
|
package/dist/update.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { execSync, spawnSync } from "node:child_process";
|
|
2
|
-
import { mkdtempSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { mkdtempSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
|
-
import { join } from "node:path";
|
|
5
|
+
import { dirname, join } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
6
7
|
import { isPortableInstall } from "./config.js";
|
|
7
8
|
const require = createRequire(import.meta.url);
|
|
8
9
|
const pkg = require("../package.json");
|
|
@@ -106,13 +107,32 @@ async function portableSelfUpdate(latest) {
|
|
|
106
107
|
writeFileSync(tmp, script, { mode: 0o755 });
|
|
107
108
|
try {
|
|
108
109
|
execSync(`bash ${JSON.stringify(tmp)}`, { stdio: "inherit" });
|
|
109
|
-
console.log(`\n✅ 已升级到 v${latest},重新运行 u1s1 生效。`);
|
|
110
110
|
}
|
|
111
111
|
catch {
|
|
112
112
|
console.error("\n自动升级失败。请手动运行:");
|
|
113
113
|
console.error(" curl -fsSL https://u1s1.io/releases/install.sh | bash");
|
|
114
114
|
process.exit(1);
|
|
115
115
|
}
|
|
116
|
+
// 脚本退出码 0 ≠ 升级成功:安装脚本认的是官网 LATEST 版本源,它若认为
|
|
117
|
+
// 「已是最新」会原样退出(0.16.x 踩过:LATEST 没随发版同步,脚本说已是
|
|
118
|
+
// 最新,这里却报✅已升级)。以安装目录里的 VERSION 文件为准二次确认。
|
|
119
|
+
let installedVer;
|
|
120
|
+
try {
|
|
121
|
+
// 包根(~/.u1s1/u1s1-cli)旁边就是 install.sh 写的 VERSION
|
|
122
|
+
installedVer = readFileSync(join(dirname(fileURLToPath(import.meta.url)), "..", "..", "VERSION"), "utf8").trim();
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
// 老版布局没这文件,确认不了就不下结论
|
|
126
|
+
}
|
|
127
|
+
if (installedVer === latest) {
|
|
128
|
+
console.log(`\n✅ 已升级到 v${latest},重新运行 u1s1 生效。`);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
console.error(`\n⚠ 安装脚本跑完了,但没装上 v${latest}(官网版本源可能滞后,当前仍是 v${installedVer ?? VERSION})。`);
|
|
132
|
+
console.error(" 请稍后重试 u1s1 update,或手动运行:");
|
|
133
|
+
console.error(" curl -fsSL https://u1s1.io/releases/install.sh | bash");
|
|
134
|
+
process.exit(1);
|
|
135
|
+
}
|
|
116
136
|
}
|
|
117
137
|
export async function update() {
|
|
118
138
|
console.log("正在检查更新…");
|
package/package.json
CHANGED
package/scripts/patch-pi.js
CHANGED
|
@@ -11,22 +11,36 @@
|
|
|
11
11
|
* - 永不让安装失败:任何异常只提示,exit 0
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import { readFileSync, writeFileSync } from "node:fs";
|
|
14
|
+
import { readFileSync, writeFileSync, existsSync } from "node:fs";
|
|
15
15
|
import { join, dirname } from "node:path";
|
|
16
16
|
import { fileURLToPath } from "node:url";
|
|
17
|
+
import { createRequire } from "node:module";
|
|
17
18
|
|
|
18
19
|
const pkgRoot = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
)
|
|
20
|
+
|
|
21
|
+
// npm 会把依赖提升到上层 node_modules(全局安装尤其如此),
|
|
22
|
+
// 所以用模块解析算法定位 pi,而不是拼固定相对路径
|
|
23
|
+
function findPiDir() {
|
|
24
|
+
try {
|
|
25
|
+
const req = createRequire(join(pkgRoot, "package.json"));
|
|
26
|
+
return dirname(req.resolve("@earendil-works/pi-coding-agent/package.json"));
|
|
27
|
+
} catch {
|
|
28
|
+
// 兜底:从包根逐级向上找
|
|
29
|
+
let dir = pkgRoot;
|
|
30
|
+
while (true) {
|
|
31
|
+
const candidate = join(dir, "node_modules", "@earendil-works", "pi-coding-agent");
|
|
32
|
+
if (existsSync(candidate)) return candidate;
|
|
33
|
+
const parent = dirname(dir);
|
|
34
|
+
if (parent === dir) return null;
|
|
35
|
+
dir = parent;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const piDir = findPiDir();
|
|
41
|
+
const target = piDir
|
|
42
|
+
? join(piDir, "dist", "modes", "interactive", "components", "assistant-message.js")
|
|
43
|
+
: null;
|
|
30
44
|
|
|
31
45
|
// 每条 [原文, 替换后];与 patches/@earendil-works__pi-coding-agent@0.84.2.patch 等效
|
|
32
46
|
const REPLACEMENTS = [
|
|
@@ -48,6 +62,10 @@ const REPLACEMENTS = [
|
|
|
48
62
|
];
|
|
49
63
|
|
|
50
64
|
try {
|
|
65
|
+
if (!target) {
|
|
66
|
+
console.log("[u1s1] 提示: 未找到 @earendil-works/pi-coding-agent,精简 UI 空行补丁未应用(不影响使用)");
|
|
67
|
+
process.exit(0);
|
|
68
|
+
}
|
|
51
69
|
let text;
|
|
52
70
|
try {
|
|
53
71
|
text = readFileSync(target, "utf8");
|