hocai-connect 0.9.0 → 0.10.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/dist/cli.js +70 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -39734,7 +39734,7 @@ var TOOLS = {
|
|
|
39734
39734
|
],
|
|
39735
39735
|
WORK: ["Read", "Write", "Edit", "Glob", "Grep"]
|
|
39736
39736
|
};
|
|
39737
|
-
var VERSION = "0.
|
|
39737
|
+
var VERSION = "0.10.1";
|
|
39738
39738
|
function claudeArgs(job, o, port) {
|
|
39739
39739
|
const mcp = {
|
|
39740
39740
|
mcpServers: {
|
|
@@ -40217,6 +40217,31 @@ async function askPortOwner(port, origin) {
|
|
|
40217
40217
|
return null;
|
|
40218
40218
|
}
|
|
40219
40219
|
}
|
|
40220
|
+
function newerVersion(a, b) {
|
|
40221
|
+
const so = (v) => {
|
|
40222
|
+
const m = v.trim().match(/^(\d+)(?:\.(\d+))?(?:\.(\d+))?/);
|
|
40223
|
+
return m ? [Number(m[1]), Number(m[2] ?? 0), Number(m[3] ?? 0)] : null;
|
|
40224
|
+
};
|
|
40225
|
+
const x = so(a);
|
|
40226
|
+
const y = so(b);
|
|
40227
|
+
if (!x || !y) return false;
|
|
40228
|
+
for (let i = 0; i < 3; i++) {
|
|
40229
|
+
if (x[i] !== y[i]) return x[i] > y[i];
|
|
40230
|
+
}
|
|
40231
|
+
return false;
|
|
40232
|
+
}
|
|
40233
|
+
async function latestVersion(pkg = "hocai-connect") {
|
|
40234
|
+
try {
|
|
40235
|
+
const res = await fetch(`https://registry.npmjs.org/${pkg}/latest`, {
|
|
40236
|
+
signal: AbortSignal.timeout(5e3)
|
|
40237
|
+
});
|
|
40238
|
+
if (!res.ok) return null;
|
|
40239
|
+
const j = await res.json();
|
|
40240
|
+
return typeof j.version === "string" ? j.version : null;
|
|
40241
|
+
} catch {
|
|
40242
|
+
return null;
|
|
40243
|
+
}
|
|
40244
|
+
}
|
|
40220
40245
|
|
|
40221
40246
|
// apps/mcp/src/cli.ts
|
|
40222
40247
|
var HOCAI_DIR = (0, import_node_path5.join)((0, import_node_os3.homedir)(), ".hocai");
|
|
@@ -40375,8 +40400,29 @@ function goDichVu() {
|
|
|
40375
40400
|
for (const c of p.uninstall) chay(c, true);
|
|
40376
40401
|
if (p.file) (0, import_node_fs3.rmSync)(p.file, { force: true });
|
|
40377
40402
|
}
|
|
40403
|
+
var LENH = ["mcp", "run", "update", "status", "stop", "logs", "quen", "help", "--help", "-h"];
|
|
40404
|
+
var TRO_GIUP = `hocai-connect \u2014 n\u1ED1i Claude tr\xEAn m\xE1y b\u1EA1n v\xE0o hocAI
|
|
40405
|
+
|
|
40406
|
+
npx hocai-connect c\xE0i v\xE0 b\u1EADt. M\xE1y t\u1EF1 n\u1ED1i l\u1EA1i m\u1ED7i l\u1EA7n b\u1EADt m\xE1y.
|
|
40407
|
+
npx hocai-connect status \u0111ang ch\u1EA1y kh\xF4ng, d\u01B0\u1EDBi t\xE0i kho\u1EA3n n\xE0o, c\xF3 b\u1EA3n m\u1EDBi kh\xF4ng
|
|
40408
|
+
npx hocai-connect update c\u1EADp nh\u1EADt l\xEAn b\u1EA3n m\u1EDBi nh\u1EA5t
|
|
40409
|
+
npx hocai-connect stop t\u1EAFt v\xE0 g\u1EE1 d\u1ECBch v\u1EE5 n\u1EC1n (ch\xECa kho\xE1 v\u1EABn gi\u1EEF)
|
|
40410
|
+
npx hocai-connect logs 40 d\xF2ng nh\u1EADt k\xFD cu\u1ED1i
|
|
40411
|
+
npx hocai-connect quen qu\xEAn ch\xECa kho\xE1 v\xE0 g\u1EE1 h\u1EB3n kh\u1ECFi m\xE1y n\xE0y
|
|
40412
|
+
|
|
40413
|
+
B\u1EA3n c\u0169 ch\u01B0a c\xF3 l\u1EC7nh update th\xEC ch\u1EA1y: npx hocai-connect@latest`;
|
|
40378
40414
|
async function main() {
|
|
40379
40415
|
const cmd = process.argv[2];
|
|
40416
|
+
if (cmd === "help" || cmd === "--help" || cmd === "-h") {
|
|
40417
|
+
say(TRO_GIUP);
|
|
40418
|
+
return;
|
|
40419
|
+
}
|
|
40420
|
+
if (cmd && !LENH.includes(cmd)) {
|
|
40421
|
+
say(`Kh\xF4ng c\xF3 l\u1EC7nh "${cmd}".`);
|
|
40422
|
+
say("");
|
|
40423
|
+
say(TRO_GIUP);
|
|
40424
|
+
process.exit(1);
|
|
40425
|
+
}
|
|
40380
40426
|
if (cmd === "mcp") {
|
|
40381
40427
|
await buildServer(process.env.HOCAI_TOKEN ?? "").connect(new StdioServerTransport());
|
|
40382
40428
|
return;
|
|
@@ -40388,6 +40434,24 @@ async function main() {
|
|
|
40388
40434
|
say("Ch\u1EA1y l\u1EA1i `npx hocai-connect` \u0111\u1EC3 k\u1EBFt n\u1ED1i l\u1EA1i.");
|
|
40389
40435
|
return;
|
|
40390
40436
|
}
|
|
40437
|
+
if (cmd === "update") {
|
|
40438
|
+
const moi = await latestVersion();
|
|
40439
|
+
if (!moi) {
|
|
40440
|
+
say("Kh\xF4ng h\u1ECFi \u0111\u01B0\u1EE3c npm xem c\xF3 b\u1EA3n m\u1EDBi kh\xF4ng. Ki\u1EC3m tra m\u1EA1ng r\u1ED3i th\u1EED l\u1EA1i.");
|
|
40441
|
+
process.exit(1);
|
|
40442
|
+
}
|
|
40443
|
+
if (!newerVersion(moi, VERSION)) {
|
|
40444
|
+
say(`\u0110ang \u1EDF b\u1EA3n m\u1EDBi nh\u1EA5t r\u1ED3i (${VERSION}). Kh\xF4ng c\u1EA7n l\xE0m g\xEC.`);
|
|
40445
|
+
return;
|
|
40446
|
+
}
|
|
40447
|
+
say(`C\xF3 b\u1EA3n m\u1EDBi: ${VERSION} \u2192 ${moi}. \u0110ang c\u1EADp nh\u1EADt\u2026`);
|
|
40448
|
+
say("");
|
|
40449
|
+
const r = (0, import_node_child_process3.spawnSync)("npx", ["-y", `hocai-connect@${moi}`], {
|
|
40450
|
+
stdio: "inherit",
|
|
40451
|
+
shell: (0, import_node_os3.platform)() === "win32"
|
|
40452
|
+
});
|
|
40453
|
+
process.exit(r.status ?? 1);
|
|
40454
|
+
}
|
|
40391
40455
|
if (cmd === "stop") {
|
|
40392
40456
|
goDichVu();
|
|
40393
40457
|
say("\u0110\xE3 t\u1EAFt v\xE0 g\u1EE1 d\u1ECBch v\u1EE5 n\u1EC1n. Ch\xECa kho\xE1 v\u1EABn gi\u1EEF \u2014 ch\u1EA1y `npx hocai-connect` l\xE0 n\u1ED1i l\u1EA1i ngay.");
|
|
@@ -40406,6 +40470,11 @@ async function main() {
|
|
|
40406
40470
|
}
|
|
40407
40471
|
say(`\u2713 \u0110ang ch\u1EA1y \xB7 ${info.user?.ten ?? "(ch\xECa \u0111\xE3 b\u1ECB thu h\u1ED3i)"} \xB7 b\u1EA3n ${info.phienBan}`);
|
|
40408
40472
|
say(` Nh\u1EADt k\xFD: ${plan().log}`);
|
|
40473
|
+
const moi = await latestVersion();
|
|
40474
|
+
if (moi && info.phienBan && newerVersion(moi, info.phienBan)) {
|
|
40475
|
+
say("");
|
|
40476
|
+
say(` C\xF3 b\u1EA3n m\u1EDBi ${moi}. C\u1EADp nh\u1EADt: npx hocai-connect@latest update`);
|
|
40477
|
+
}
|
|
40409
40478
|
return;
|
|
40410
40479
|
}
|
|
40411
40480
|
if (cmd === "logs") {
|