zrocclaw 0.0.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/bin/zrocclaw.js +2 -0
- package/dist/index.js +79 -0
- package/package.json +24 -0
package/bin/zrocclaw.js
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const commander_1 = require("commander");
|
|
7
|
+
const child_process_1 = require("child_process");
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const os_1 = __importDefault(require("os"));
|
|
11
|
+
const program = new commander_1.Command();
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
13
|
+
const packageJson = require("../package.json");
|
|
14
|
+
const PID_FILE = path_1.default.join(os_1.default.homedir(), ".zrocclaw.pid");
|
|
15
|
+
program
|
|
16
|
+
.name("zrocclaw")
|
|
17
|
+
.description(packageJson.description)
|
|
18
|
+
.version(packageJson.version);
|
|
19
|
+
program
|
|
20
|
+
.command("start")
|
|
21
|
+
.description("启动 ZrocClaw 后台服务")
|
|
22
|
+
.action(() => {
|
|
23
|
+
if (fs_1.default.existsSync(PID_FILE)) {
|
|
24
|
+
console.log(`⚠️ ZrocClaw 服务已在运行 (PID: ${fs_1.default.readFileSync(PID_FILE, "utf-8").trim()})`);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
// 动态解析 @zrocclaw/gateway 包的入口路径
|
|
29
|
+
const serverPath = require.resolve("@zrocclaw/gateway/dist/server.js");
|
|
30
|
+
const child = (0, child_process_1.spawn)("node", [serverPath], {
|
|
31
|
+
detached: true,
|
|
32
|
+
stdio: "ignore",
|
|
33
|
+
env: { ...process.env, NODE_ENV: "production" }
|
|
34
|
+
});
|
|
35
|
+
if (child.pid) {
|
|
36
|
+
fs_1.default.writeFileSync(PID_FILE, child.pid.toString());
|
|
37
|
+
console.log(`✅ ZrocClaw 服务已在后台启动 (PID: ${child.pid})`);
|
|
38
|
+
console.log(`🌍 请在浏览器访问体验,默认端口请参考网关配置。`);
|
|
39
|
+
}
|
|
40
|
+
child.unref();
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
console.error("❌ 启动失败:找不到 @zrocclaw/gateway 模块,请确认它已正确安装和编译。");
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
program
|
|
47
|
+
.command("stop")
|
|
48
|
+
.description("停止 ZrocClaw 服务")
|
|
49
|
+
.action(() => {
|
|
50
|
+
if (!fs_1.default.existsSync(PID_FILE)) {
|
|
51
|
+
console.log("❌ 未找到运行中的 ZrocClaw 服务记录");
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const pid = parseInt(fs_1.default.readFileSync(PID_FILE, "utf-8").trim(), 10);
|
|
55
|
+
try {
|
|
56
|
+
process.kill(pid);
|
|
57
|
+
console.log(`✅ ZrocClaw 服务 (PID: ${pid}) 已停止`);
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
console.log(`⚠️ 进程 ${pid} 不存在,可能已被关闭。`);
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
fs_1.default.unlinkSync(PID_FILE);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
program
|
|
67
|
+
.command("update")
|
|
68
|
+
.description("全局更新 ZrocClaw 到最新版本")
|
|
69
|
+
.action(() => {
|
|
70
|
+
console.log("⏳ 正在检查并更新 ZrocClaw...");
|
|
71
|
+
try {
|
|
72
|
+
(0, child_process_1.execSync)("npm install -g zrocclaw@latest", { stdio: "inherit" });
|
|
73
|
+
console.log("✅ 更新完成!");
|
|
74
|
+
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
console.error("❌ 更新失败,请检查网络或权限");
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
program.parse(process.argv);
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "zrocclaw",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "个人专属浏览器AI助手命令行工具",
|
|
5
|
+
"bin": {
|
|
6
|
+
"zrocclaw": "bin/zrocclaw.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"bin"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"dev": "tsc --watch",
|
|
14
|
+
"build": "tsc"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@zrocclaw/gateway": "workspace:*",
|
|
18
|
+
"commander": "^12.1.0"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/node": "^24.12.0",
|
|
22
|
+
"typescript": "^5.9.3"
|
|
23
|
+
}
|
|
24
|
+
}
|