@zshuangmu/agenthub 0.3.7 → 0.3.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/package.json +1 -1
- package/src/cli.js +29 -9
- package/src/commands/pack.js +3 -1
- package/src/lib/manifest.js +2 -2
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -111,11 +111,13 @@ agenthub pack - 打包 Agent
|
|
|
111
111
|
--workspace <dir> OpenClaw 工作区目录 (必需)
|
|
112
112
|
--config <file> openclaw.json 配置文件路径 (必需)
|
|
113
113
|
--output <dir> 输出目录 (默认: ./bundles)
|
|
114
|
+
--version <ver> 版本号 (默认: 1.0.0)
|
|
114
115
|
--tags <tags> 标签,逗号分隔
|
|
115
116
|
--category <cat> 分类
|
|
116
117
|
|
|
117
118
|
示例:
|
|
118
119
|
agenthub pack --workspace ./my-agent --config ./openclaw.json
|
|
120
|
+
agenthub pack --workspace ./my-agent --config ./openclaw.json --version 2.0.0
|
|
119
121
|
`,
|
|
120
122
|
publish: `
|
|
121
123
|
agenthub publish - 发布 Agent
|
|
@@ -284,11 +286,7 @@ function parseArgs(argv) {
|
|
|
284
286
|
const options = {};
|
|
285
287
|
for (let index = 0; index < argv.length; index += 1) {
|
|
286
288
|
const token = argv[index];
|
|
287
|
-
if (token
|
|
288
|
-
options.help = true;
|
|
289
|
-
} else if (token === "--version" || token === "-v") {
|
|
290
|
-
options.version = true;
|
|
291
|
-
} else if (token.startsWith("--")) {
|
|
289
|
+
if (token.startsWith("--")) {
|
|
292
290
|
const rawKey = token.slice(2);
|
|
293
291
|
const camelKey = rawKey.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
294
292
|
const value = argv[index + 1];
|
|
@@ -300,6 +298,10 @@ function parseArgs(argv) {
|
|
|
300
298
|
options[rawKey] = true;
|
|
301
299
|
options[camelKey] = true;
|
|
302
300
|
}
|
|
301
|
+
} else if (token === "-h") {
|
|
302
|
+
options.help = true;
|
|
303
|
+
} else if (token === "-v") {
|
|
304
|
+
options.version = true;
|
|
303
305
|
} else {
|
|
304
306
|
positionals.push(token);
|
|
305
307
|
}
|
|
@@ -311,8 +313,8 @@ async function main() {
|
|
|
311
313
|
const { positionals, options } = parseArgs(process.argv.slice(2));
|
|
312
314
|
const [command, ...rest] = positionals;
|
|
313
315
|
|
|
314
|
-
// 全局选项
|
|
315
|
-
if (options.version) {
|
|
316
|
+
// 全局选项 - only show version if --version/-v is a boolean flag, not a string value
|
|
317
|
+
if (options.version === true) {
|
|
316
318
|
console.log(`AgentHub v${VERSION}`);
|
|
317
319
|
return;
|
|
318
320
|
}
|
|
@@ -527,14 +529,32 @@ async function main() {
|
|
|
527
529
|
console.log(`\n${warning("建议:")}`);
|
|
528
530
|
console.log(` - 检查文件权限`);
|
|
529
531
|
console.log(` - 尝试使用 ${highlight("sudo")} 命令`);
|
|
530
|
-
} else if (errMsg.includes("network") || errMsg.includes("econnrefused") || errMsg.includes("timeout")) {
|
|
532
|
+
} else if (errMsg.includes("network") || errMsg.includes("econnrefused") || errMsg.includes("timeout") || errMsg.includes("fetch failed")) {
|
|
531
533
|
console.log(`\n${warning("建议:")}`);
|
|
532
534
|
console.log(` - 检查网络连接`);
|
|
533
535
|
console.log(` - 确认服务器地址正确`);
|
|
534
536
|
console.log(` - 使用 ${highlight("--registry")} 指定本地 registry`);
|
|
537
|
+
console.log(` - 运行 ${highlight("agenthub doctor")} 诊断环境问题`);
|
|
538
|
+
} else if (errMsg.includes("agent not found") || errMsg.includes("no agent")) {
|
|
539
|
+
console.log(`\n${warning("建议:")}`);
|
|
540
|
+
console.log(` - 运行 ${highlight("agenthub search")} 查看可用 Agent`);
|
|
541
|
+
console.log(` - 检查 Agent 名称拼写`);
|
|
542
|
+
console.log(` - 确认使用正确的 --registry 路径`);
|
|
543
|
+
} else if (errMsg.includes("invalid") || errMsg.includes("validation")) {
|
|
544
|
+
console.log(`\n${warning("建议:")}`);
|
|
545
|
+
console.log(` - 检查配置文件格式 (openclaw.json)`);
|
|
546
|
+
console.log(` - 确认 workspace 包含必需文件 (AGENTS.md, SOUL.md 等)`);
|
|
547
|
+
console.log(` - 运行 ${highlight("agenthub verify")} 检查安装完整性`);
|
|
548
|
+
} else if (errMsg.includes("version") || errMsg.includes("already")) {
|
|
549
|
+
console.log(`\n${warning("建议:")}`);
|
|
550
|
+
console.log(` - 运行 ${highlight("agenthub versions <agent>")} 查看可用版本`);
|
|
551
|
+
console.log(` - 使用 ${highlight("--force")} 强制覆盖安装`);
|
|
552
|
+
console.log(` - 运行 ${highlight("agenthub list")} 查看已安装的 Agent`);
|
|
535
553
|
}
|
|
536
554
|
|
|
537
|
-
console.log(`\n${muted("
|
|
555
|
+
console.log(`\n${muted("如需更多帮助:")}`);
|
|
556
|
+
console.log(`${muted(" - 运行: agenthub <command> --help")}`);
|
|
557
|
+
console.log(`${muted(" - 诊断: agenthub doctor")}`);
|
|
538
558
|
process.exitCode = 1;
|
|
539
559
|
}
|
|
540
560
|
}
|
package/src/commands/pack.js
CHANGED
|
@@ -67,10 +67,11 @@ export async function packCommand(options) {
|
|
|
67
67
|
const workspace = path.resolve(options.workspace || process.cwd());
|
|
68
68
|
const output = path.resolve(options.output ?? "./bundles");
|
|
69
69
|
const configPath = options.config ? path.resolve(options.config) : null;
|
|
70
|
+
const version = options.version || "1.0.0";
|
|
70
71
|
|
|
71
72
|
// 从工作区名称生成 slug
|
|
72
73
|
const slug = path.basename(workspace).toLowerCase().replace(/[^a-z0-9-]/g, "-");
|
|
73
|
-
const bundleDir = path.join(output, `${slug}
|
|
74
|
+
const bundleDir = path.join(output, `${slug}-${version}.agent`);
|
|
74
75
|
|
|
75
76
|
// 1. 扫描工作区
|
|
76
77
|
const workspaceFiles = await scanWorkspace(workspace);
|
|
@@ -99,6 +100,7 @@ export async function packCommand(options) {
|
|
|
99
100
|
prompts: workspaceFiles.prompts,
|
|
100
101
|
tags: options.tags ? options.tags.split(",").map((t) => t.trim()) : [],
|
|
101
102
|
category: options.category,
|
|
103
|
+
version,
|
|
102
104
|
});
|
|
103
105
|
|
|
104
106
|
// 5. 验证 MANIFEST
|
package/src/lib/manifest.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
const WORKSPACE_FILES = ["AGENTS.md", "SOUL.md", "USER.md", "IDENTITY.md", "TOOLS.md", "HEARTBEAT.md", "BOOTSTRAP.md"];
|
|
7
7
|
|
|
8
|
-
export function createManifest({ slug, name, description, author, memoryCounts, openclawTemplate, skills = [], prompts = [], tags = [], category, language = "zh-CN" }) {
|
|
8
|
+
export function createManifest({ slug, name, description, author, memoryCounts, openclawTemplate, skills = [], prompts = [], tags = [], category, language = "zh-CN", version = "1.0.0" }) {
|
|
9
9
|
const hasModel = openclawTemplate?.agents?.defaults?.model?.primary;
|
|
10
10
|
const totalMemory = memoryCounts.public + memoryCounts.portable + memoryCounts.private;
|
|
11
11
|
|
|
@@ -13,7 +13,7 @@ export function createManifest({ slug, name, description, author, memoryCounts,
|
|
|
13
13
|
// 基本信息
|
|
14
14
|
name: name || slug,
|
|
15
15
|
slug,
|
|
16
|
-
version
|
|
16
|
+
version,
|
|
17
17
|
description: description || `OpenClaw agent bundle for ${name || slug}`,
|
|
18
18
|
author: author || "anonymous",
|
|
19
19
|
icon: undefined,
|