@zshuangmu/agenthub 0.2.0 → 0.2.1
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/package.json +1 -1
- package/src/commands/rollback.js +11 -1
- package/src/commands/update.js +11 -2
- package/src/commands/verify.js +44 -5
package/package.json
CHANGED
package/src/commands/rollback.js
CHANGED
|
@@ -8,6 +8,7 @@ import { getCurrentVersion, updateInstallRecord, buildInstallOptions } from "../
|
|
|
8
8
|
import { installBundle } from "../lib/install.js";
|
|
9
9
|
import { parseSpec } from "../lib/registry.js";
|
|
10
10
|
import { versionsCommand } from "./versions.js";
|
|
11
|
+
import { success, warning, highlight, muted, symbols } from "../lib/colors.js";
|
|
11
12
|
|
|
12
13
|
export async function rollbackCommand(agentSpec, options = {}) {
|
|
13
14
|
const targetWorkspace = options.targetWorkspace ? path.resolve(options.targetWorkspace) : null;
|
|
@@ -41,7 +42,16 @@ export async function rollbackCommand(agentSpec, options = {}) {
|
|
|
41
42
|
|
|
42
43
|
return {
|
|
43
44
|
rolledBack: true,
|
|
44
|
-
message:
|
|
45
|
+
message: [
|
|
46
|
+
success(`${symbols.success} 回滚成功`),
|
|
47
|
+
"",
|
|
48
|
+
` ${highlight("Agent:")} ${slug}`,
|
|
49
|
+
` ${muted("回滚前:")} ${currentVersion || "未知"}`,
|
|
50
|
+
` ${highlight("当前版本:")} ${targetVersion}`,
|
|
51
|
+
"",
|
|
52
|
+
` ${muted("运行")} ${highlight("agenthub verify " + slug)} ${muted("校验安装状态")}`,
|
|
53
|
+
` ${muted("运行")} ${highlight("agenthub update " + slug)} ${muted("恢复到最新版本")}`,
|
|
54
|
+
].join("\n"),
|
|
45
55
|
currentVersion: targetVersion,
|
|
46
56
|
previousVersion: currentVersion,
|
|
47
57
|
manifest: result.manifest,
|
package/src/commands/update.js
CHANGED
|
@@ -7,6 +7,7 @@ import path from "node:path";
|
|
|
7
7
|
import { getCurrentVersion, performVersionChange } from "../lib/version-manager.js";
|
|
8
8
|
import { parseSpec } from "../lib/registry.js";
|
|
9
9
|
import { versionsCommand } from "./versions.js";
|
|
10
|
+
import { success, warning, highlight, muted, symbols } from "../lib/colors.js";
|
|
10
11
|
|
|
11
12
|
export async function updateCommand(agentSpec, options = {}) {
|
|
12
13
|
const targetWorkspace = options.targetWorkspace ? path.resolve(options.targetWorkspace) : null;
|
|
@@ -26,7 +27,7 @@ export async function updateCommand(agentSpec, options = {}) {
|
|
|
26
27
|
if (currentVersion === latestVersion) {
|
|
27
28
|
return {
|
|
28
29
|
updated: false,
|
|
29
|
-
message:
|
|
30
|
+
message: `${success(`${symbols.success} ${slug} 已是最新版本`)} ${muted(`(${latestVersion})`)}`,
|
|
30
31
|
currentVersion,
|
|
31
32
|
latestVersion,
|
|
32
33
|
};
|
|
@@ -37,7 +38,15 @@ export async function updateCommand(agentSpec, options = {}) {
|
|
|
37
38
|
|
|
38
39
|
return {
|
|
39
40
|
updated: true,
|
|
40
|
-
message:
|
|
41
|
+
message: [
|
|
42
|
+
success(`${symbols.success} 更新成功`),
|
|
43
|
+
"",
|
|
44
|
+
` ${highlight("Agent:")} ${slug}`,
|
|
45
|
+
` ${muted("旧版本:")} ${currentVersion || "未知"}`,
|
|
46
|
+
` ${highlight("新版本:")} ${latestVersion}`,
|
|
47
|
+
"",
|
|
48
|
+
` ${muted("运行")} ${highlight("agenthub verify " + slug)} ${muted("校验安装状态")}`,
|
|
49
|
+
].join("\n"),
|
|
41
50
|
currentVersion: latestVersion,
|
|
42
51
|
previousVersion: currentVersion,
|
|
43
52
|
manifest: result.manifest,
|
package/src/commands/verify.js
CHANGED
|
@@ -2,6 +2,7 @@ import path from "node:path";
|
|
|
2
2
|
import { pathExists, readJson } from "../lib/fs-utils.js";
|
|
3
3
|
import { parseSpec } from "../lib/registry.js";
|
|
4
4
|
import { infoCommand } from "./info.js";
|
|
5
|
+
import { success, error, warning, info as infoColor, highlight, muted, symbols } from "../lib/colors.js";
|
|
5
6
|
|
|
6
7
|
export async function verifyCommand(agentSpec, options = {}) {
|
|
7
8
|
const targetWorkspace = path.resolve(options.targetWorkspace || process.cwd());
|
|
@@ -78,17 +79,55 @@ export async function verifyCommand(agentSpec, options = {}) {
|
|
|
78
79
|
|
|
79
80
|
export function formatVerifyOutput(result) {
|
|
80
81
|
const lines = [];
|
|
81
|
-
|
|
82
|
+
|
|
83
|
+
// 标题
|
|
84
|
+
if (result.verified) {
|
|
85
|
+
lines.push(`\n${success(`${symbols.success} 校验通过`)}\n`);
|
|
86
|
+
} else {
|
|
87
|
+
lines.push(`\n${error(`${symbols.error} 校验失败`)}\n`);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Agent 信息
|
|
82
91
|
if (result.installRecord) {
|
|
83
|
-
lines.push(
|
|
92
|
+
lines.push(`${highlight("Agent:")} ${result.installRecord.slug}@${result.installRecord.version}`);
|
|
84
93
|
}
|
|
85
|
-
lines.push(
|
|
94
|
+
lines.push(`${highlight("Workspace:")} ${result.targetWorkspace}`);
|
|
86
95
|
lines.push("");
|
|
96
|
+
|
|
97
|
+
// 检查结果
|
|
98
|
+
lines.push(`${infoColor("检查项目:")}`);
|
|
87
99
|
for (const check of result.checks || []) {
|
|
88
|
-
|
|
100
|
+
const status = check.ok
|
|
101
|
+
? success(`${symbols.success} PASS`)
|
|
102
|
+
: error(`${symbols.error} FAIL`);
|
|
103
|
+
const checkName = check.name.replace(":", ": ").replace("_", " ");
|
|
104
|
+
lines.push(` ${status} ${muted(checkName)}`);
|
|
105
|
+
if (!check.ok || check.name.includes(":")) {
|
|
106
|
+
lines.push(` ${muted(check.detail)}`);
|
|
107
|
+
}
|
|
89
108
|
}
|
|
109
|
+
|
|
110
|
+
// 失败原因
|
|
90
111
|
if (result.reason) {
|
|
91
|
-
lines.push(`\
|
|
112
|
+
lines.push(`\n${warning(`原因: ${result.reason}`)}`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// 健康度建议
|
|
116
|
+
if (result.verified) {
|
|
117
|
+
lines.push(`\n${success("Agent 安装完整,可以正常使用。")}`);
|
|
118
|
+
} else {
|
|
119
|
+
lines.push(`\n${warning("建议:")}`);
|
|
120
|
+
if (result.checks?.some(c => c.name === "install_record" && !c.ok)) {
|
|
121
|
+
lines.push(` - 运行 ${highlight("agenthub install <agent-slug>")} 安装 Agent`);
|
|
122
|
+
}
|
|
123
|
+
if (result.checks?.some(c => c.name.includes("workspace_file") && !c.ok)) {
|
|
124
|
+
lines.push(` - 检查 workspace 文件是否完整`);
|
|
125
|
+
lines.push(` - 尝试重新安装: ${highlight("agenthub install <agent-slug> --force")}`);
|
|
126
|
+
}
|
|
127
|
+
if (result.checks?.some(c => c.name === "applied_config" && !c.ok)) {
|
|
128
|
+
lines.push(` - 配置文件未应用,检查 OPENCLAW.template.json`);
|
|
129
|
+
}
|
|
92
130
|
}
|
|
131
|
+
|
|
93
132
|
return lines.join("\n");
|
|
94
133
|
}
|