hocai-connect 0.9.0 → 0.10.0

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.
Files changed (2) hide show
  1. package/dist/cli.js +49 -1
  2. 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.9.0";
39737
+ var VERSION = "0.10.0";
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");
@@ -40388,6 +40413,24 @@ async function main() {
40388
40413
  say("Ch\u1EA1y l\u1EA1i `npx hocai-connect` \u0111\u1EC3 k\u1EBFt n\u1ED1i l\u1EA1i.");
40389
40414
  return;
40390
40415
  }
40416
+ if (cmd === "update") {
40417
+ const moi = await latestVersion();
40418
+ if (!moi) {
40419
+ 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.");
40420
+ process.exit(1);
40421
+ }
40422
+ if (!newerVersion(moi, VERSION)) {
40423
+ say(`\u0110ang \u1EDF b\u1EA3n m\u1EDBi nh\u1EA5t r\u1ED3i (${VERSION}). Kh\xF4ng c\u1EA7n l\xE0m g\xEC.`);
40424
+ return;
40425
+ }
40426
+ say(`C\xF3 b\u1EA3n m\u1EDBi: ${VERSION} \u2192 ${moi}. \u0110ang c\u1EADp nh\u1EADt\u2026`);
40427
+ say("");
40428
+ const r = (0, import_node_child_process3.spawnSync)("npx", ["-y", `hocai-connect@${moi}`], {
40429
+ stdio: "inherit",
40430
+ shell: (0, import_node_os3.platform)() === "win32"
40431
+ });
40432
+ process.exit(r.status ?? 1);
40433
+ }
40391
40434
  if (cmd === "stop") {
40392
40435
  goDichVu();
40393
40436
  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 +40449,11 @@ async function main() {
40406
40449
  }
40407
40450
  say(`\u2713 \u0110ang ch\u1EA1y \xB7 ${info.user?.ten ?? "(ch\xECa \u0111\xE3 b\u1ECB thu h\u1ED3i)"} \xB7 b\u1EA3n ${info.phienBan}`);
40408
40451
  say(` Nh\u1EADt k\xFD: ${plan().log}`);
40452
+ const moi = await latestVersion();
40453
+ if (moi && info.phienBan && newerVersion(moi, info.phienBan)) {
40454
+ say("");
40455
+ say(` C\xF3 b\u1EA3n m\u1EDBi ${moi}. C\u1EADp nh\u1EADt: npx hocai-connect@latest update`);
40456
+ }
40409
40457
  return;
40410
40458
  }
40411
40459
  if (cmd === "logs") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hocai-connect",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Nối Claude trên máy học viên vào hocAI, và chạy việc AI ngay tại đó",
5
5
  "bin": {
6
6
  "hocai-connect": "bin.js"