@saltpub/agent-autoloop 0.1.8 → 0.1.9
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/CHANGELOG.md +7 -0
- package/dist/bin/agent-autoloop.js +6 -1
- package/dist/cli/main.js +8 -2
- package/dist/host/update.js +27 -3
- package/docs/auto-update.md +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @saltpub/agent-autoloop
|
|
2
2
|
|
|
3
|
+
## 0.1.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d7a8b22: 修好 0.1.8 装不上:`update` 把新版本装到 `versions/` 后会先试跑它,但新副本的 shim 把自己转手给了正在跑的旧版,试跑看到的版本号不对,于是报「起不来」并把新副本删掉。现在 `versions/` 下的受管副本一律运行自己,只有 npm 全局安装跟随指针。
|
|
8
|
+
- 6d1bbc6: `agent-autoloop update` 装好新版本(或新版本已经在等重启)时,列出这一版的更新内容,取自包里的 CHANGELOG,不再只显示一个版本号。
|
|
9
|
+
|
|
3
10
|
## 0.1.8
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// AGENT_AUTOLOOP_SHIM_V1 — version shim, rustup-style. The npm global install resolves the self-update pointer and
|
|
3
3
|
// re-runs the versioned copy, so a command follows the version the hub runs after an update instead of the stale
|
|
4
4
|
// global package. Every failure mode (no pointer, corrupt JSON, missing target, a pointer naming this very
|
|
5
|
-
// install, a git checkout) falls back to this package's own CLI —
|
|
5
|
+
// install, a git checkout, a copy the updater unpacked under versions/) falls back to this package's own CLI —
|
|
6
|
+
// the behaviour before the shim.
|
|
6
7
|
import { spawn } from "node:child_process";
|
|
7
8
|
import { existsSync, readFileSync } from "node:fs";
|
|
8
9
|
import { homedir } from "node:os";
|
|
@@ -14,6 +15,10 @@ const ROOT = COMPILED ? path.dirname(path.dirname(HERE)) : path.dirname(HERE);
|
|
|
14
15
|
const HOME = process.env.AGENT_AUTOLOOP_HOME?.trim() || path.join(homedir(), ".agent-autoloop");
|
|
15
16
|
/** The managed copy's entry, or undefined to fall back to this package. */
|
|
16
17
|
function pointedEntry() {
|
|
18
|
+
// A copy the updater unpacked under versions/ runs as itself: the trial run checks this very version, and the
|
|
19
|
+
// launcher names the copy to start. Only an install outside versions/ (the npm global one) follows the pointer.
|
|
20
|
+
if (path.resolve(ROOT).startsWith(`${path.resolve(path.join(HOME, "versions"))}${path.sep}`))
|
|
21
|
+
return undefined;
|
|
17
22
|
let pointer;
|
|
18
23
|
try {
|
|
19
24
|
pointer = JSON.parse(readFileSync(path.join(HOME, "update", "current.json"), "utf8"));
|
package/dist/cli/main.js
CHANGED
|
@@ -1078,8 +1078,12 @@ async function update() {
|
|
|
1078
1078
|
const result = stageLatest();
|
|
1079
1079
|
if (result.status === "current")
|
|
1080
1080
|
return console.log(`已经是最新的(v${result.version})。`);
|
|
1081
|
-
if (result.status === "pending")
|
|
1082
|
-
|
|
1081
|
+
if (result.status === "pending") {
|
|
1082
|
+
console.log(`v${result.version} 已经准备好,中台重启时换上。`);
|
|
1083
|
+
for (const note of result.notes)
|
|
1084
|
+
console.log(`- ${note}`);
|
|
1085
|
+
return;
|
|
1086
|
+
}
|
|
1083
1087
|
if (result.status === "bad")
|
|
1084
1088
|
return fail(`v${result.version} 之前启动失败过,先不装它;修好后删掉 ${path.join(HOME, "update", "bad.json")} 再试。`);
|
|
1085
1089
|
if (result.status === "busy")
|
|
@@ -1091,6 +1095,8 @@ async function update() {
|
|
|
1091
1095
|
if (told === undefined && service)
|
|
1092
1096
|
await waitForHub();
|
|
1093
1097
|
console.log(`更新好了(v${result.version})。${told ?? (service ? "" : "下次启动中台时换上。")}`);
|
|
1098
|
+
for (const note of result.notes)
|
|
1099
|
+
console.log(`- ${note}`);
|
|
1094
1100
|
}
|
|
1095
1101
|
async function askAtTerminal(question) {
|
|
1096
1102
|
const terminal = createInterface({ input: process.stdin, output: process.stdout });
|
package/dist/host/update.js
CHANGED
|
@@ -63,6 +63,28 @@ export function readPending(home = HOME) {
|
|
|
63
63
|
return null;
|
|
64
64
|
return pending;
|
|
65
65
|
}
|
|
66
|
+
/** The bullets this version's CHANGELOG section lists, commit hashes stripped. [] when there is nothing to show. */
|
|
67
|
+
export function releaseNotes(dir, version) {
|
|
68
|
+
let changelog;
|
|
69
|
+
try {
|
|
70
|
+
changelog = readFileSync(path.join(dir, "CHANGELOG.md"), "utf8");
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
const notes = [];
|
|
76
|
+
let inside = false;
|
|
77
|
+
for (const line of changelog.split("\n")) {
|
|
78
|
+
if (line.startsWith("## ")) {
|
|
79
|
+
inside = line.trimEnd() === `## ${version}`;
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const bullet = /^- (?:[0-9a-f]{7,}: )?(.+?)\s*$/.exec(line.trimStart());
|
|
83
|
+
if (inside && bullet)
|
|
84
|
+
notes.push(bullet[1]);
|
|
85
|
+
}
|
|
86
|
+
return notes;
|
|
87
|
+
}
|
|
66
88
|
export function managedAt(home = HOME) {
|
|
67
89
|
return readPointer(home) !== null && existsSync(launcherFile(home));
|
|
68
90
|
}
|
|
@@ -250,8 +272,10 @@ export function stageLatest(home = HOME) {
|
|
|
250
272
|
return { status: "current", version: pointer.version };
|
|
251
273
|
if (badVersions(home).includes(latest))
|
|
252
274
|
return { status: "bad", version: latest };
|
|
253
|
-
|
|
254
|
-
|
|
275
|
+
const waiting = readPending(home);
|
|
276
|
+
if (waiting?.version === latest) {
|
|
277
|
+
return { status: "pending", version: latest, notes: releaseNotes(waiting.dir, latest) };
|
|
278
|
+
}
|
|
255
279
|
const lock = acquireLock(home);
|
|
256
280
|
if (!lock)
|
|
257
281
|
return { status: "busy" };
|
|
@@ -273,7 +297,7 @@ export function stageLatest(home = HOME) {
|
|
|
273
297
|
throw new Error(`${PACKAGE}@${latest} 起不来:${done.stderr?.trim() || done.stdout?.trim() || done.error}`);
|
|
274
298
|
}
|
|
275
299
|
writeJson(pendingFile(home), { version: latest, dir, at: Date.now() });
|
|
276
|
-
return { status: "staged", version: latest };
|
|
300
|
+
return { status: "staged", version: latest, notes: releaseNotes(dir, latest) };
|
|
277
301
|
}
|
|
278
302
|
catch (error) {
|
|
279
303
|
rmSync(prefix, { recursive: true, force: true });
|
package/docs/auto-update.md
CHANGED
|
@@ -34,7 +34,7 @@ npm 安装的副本不在原地覆盖着换版本。每个版本解包在自己
|
|
|
34
34
|
|
|
35
35
|
## 手动更新
|
|
36
36
|
|
|
37
|
-
`agent-autoloop update` 先数没跑完的轮次,有就拒绝。没有就做上面第 1 到第 3 步,然后重启服务;没装服务时,下次 `up`
|
|
37
|
+
`agent-autoloop update` 先数没跑完的轮次,有就拒绝。没有就做上面第 1 到第 3 步,然后重启服务;没装服务时,下次 `up` 换上。装好或已经在等的版本,会把这一版的更新内容(包里 CHANGELOG 的条目)一并列出来。
|
|
38
38
|
|
|
39
39
|
`update` 只准备版本,不改 `rules.json`、密钥和记录。投影格式变了会在新版第一次启动时从日志重建,见 [安装说明](../INSTALL.md)。
|
|
40
40
|
|